Default files/directories to at least 0444/0555 mode.
authorshort <>
Sat, 29 Nov 2003 18:35:12 +0000 (18:35 +0000)
committershort <>
Sat, 29 Nov 2003 18:35:12 +0000 (18:35 +0000)
 - It is the expected common filesystem default.
 - Overridable by LUFS: fmode=666,dmode=777 or fmode
+LUFS mount option 'private' to get the former 0600/0700 mode.

src/client/lufs/captivefs-attr.c
src/client/lufs/captivefs-attr.h
src/client/lufs/captivefs-directory.c
src/client/lufs/captivefs-file.c
src/client/lufs/captivefs-vfs.c
src/client/lufs/captivefs-vfs.h
src/client/lufs/mount.captive.pod.pl.in

index 55856b7..a1142f1 100644 (file)
 #include "captivefs-attr.h"    /* self */
 #include <glib/gmessages.h>
 #include <time.h>
+#include "captivefs-vfs.h"
 
 
-gboolean captivefs_GnomeVFSFileInfo_to_lufs_fattr(struct lufs_fattr *fattr,const GnomeVFSFileInfo *file_info)
+gboolean captivefs_GnomeVFSFileInfo_to_lufs_fattr
+               (struct captivefs_vfs *captivefs_vfs,struct lufs_fattr *fattr,const GnomeVFSFileInfo *file_info)
 {
+       g_return_val_if_fail(captivefs_vfs_validate(captivefs_vfs),FALSE);
        g_return_val_if_fail(fattr!=NULL,FALSE);
        g_return_val_if_fail(file_info!=NULL,FALSE);
 
@@ -33,8 +36,18 @@ gboolean captivefs_GnomeVFSFileInfo_to_lufs_fattr(struct lufs_fattr *fattr,const
 
        if (file_info->valid_fields&GNOME_VFS_FILE_INFO_FIELDS_TYPE)
                switch (file_info->type) {
-                       case GNOME_VFS_FILE_TYPE_REGULAR:   fattr->f_mode|=S_IFREG; break;
-                       case GNOME_VFS_FILE_TYPE_DIRECTORY: fattr->f_mode|=S_IFDIR; break;
+                       case GNOME_VFS_FILE_TYPE_REGULAR:
+                               fattr->f_mode|=S_IFREG;
+                               /* 'fmode' kernel LUFS option only |= to our reported 'f_mode': */
+                               if (!captivefs_vfs->private)
+                                       fattr->f_mode|=0444;
+                               break;
+                       case GNOME_VFS_FILE_TYPE_DIRECTORY:
+                               fattr->f_mode|=S_IFDIR;
+                               /* 'dmode' kernel LUFS option only |= to our reported 'f_mode': */
+                               if (!captivefs_vfs->private)
+                                       fattr->f_mode|=0555;
+                               break;
                        default:
                                g_warning("Unknown GnomeVFSFileInfo.type=%d of: %s",(int)file_info->type,file_info->name);
                                return FALSE;
index ad0a5c2..c6f6e4e 100644 (file)
 
 #include <glib/gtypes.h>
 #include <libgnomevfs/gnome-vfs-file-info.h>
+#include "captivefs-vfs.h"
 
 #include <lufs/proto.h>
 
 
 G_BEGIN_DECLS
 
-gboolean captivefs_GnomeVFSFileInfo_to_lufs_fattr(struct lufs_fattr *fattr,const GnomeVFSFileInfo *file_info);
+gboolean captivefs_GnomeVFSFileInfo_to_lufs_fattr
+               (struct captivefs_vfs *captivefs_vfs,struct lufs_fattr *fattr,const GnomeVFSFileInfo *file_info);
 gboolean captivefs_lufs_fattr_to_GnomeVFSFileInfo(GnomeVFSFileInfo *file_info,const struct lufs_fattr *fattr);
 
 G_END_DECLS
index 7773f3e..692790f 100644 (file)
@@ -69,7 +69,7 @@ const char *dots[]={".","..",NULL},**csp;
 
        file_info.valid_fields=GNOME_VFS_FILE_INFO_FIELDS_TYPE;
        file_info.type=GNOME_VFS_FILE_TYPE_DIRECTORY;
-       if (!captivefs_GnomeVFSFileInfo_to_lufs_fattr(&fattr,&file_info))
+       if (!captivefs_GnomeVFSFileInfo_to_lufs_fattr(captivefs_vfs,&fattr,&file_info))
                goto fail_unref;
        for (csp=dots;*csp;csp++)
                if (0>lu_cache_add2dir(ddir,(/* de-const */ char *)*csp,NULL,&fattr)) {
@@ -88,7 +88,7 @@ const char *dots[]={".","..",NULL},**csp;
                if (errvfsresult!=GNOME_VFS_OK)
                        goto fail_unref;
 
-               if (!captivefs_GnomeVFSFileInfo_to_lufs_fattr(&fattr,&file_info))
+               if (!captivefs_GnomeVFSFileInfo_to_lufs_fattr(captivefs_vfs,&fattr,&file_info))
                        goto fail_unref;
 
                if (0>lu_cache_add2dir(ddir,file_info.name,NULL,&fattr)) {
index 0dc7b4d..611689e 100644 (file)
@@ -265,7 +265,7 @@ GnomeVFSFileInfo file_info;
        if (errvfsresult!=GNOME_VFS_OK)
                return -1;
 
-       if (!captivefs_GnomeVFSFileInfo_to_lufs_fattr(fattr,&file_info))
+       if (!captivefs_GnomeVFSFileInfo_to_lufs_fattr(captivefs_vfs,fattr,&file_info))
                return -1;
 
        return 0;
index 1371e56..188442a 100644 (file)
@@ -113,6 +113,7 @@ gchar *gs,*captive_options_string;
 
        captive_new(captivefs_vfs);
        captivefs_vfs->captive_vfs_object=NULL;
+       captivefs_vfs->private=FALSE;
        captivefs_vfs->parent_pid=getpid();
        captivefs_vfs->global_ctx=global_ctx;
        *global_ctx=captivefs_vfs;
@@ -133,6 +134,8 @@ gchar *gs,*captive_options_string;
                                captive_options_string))        /* captive_args */
                        goto fail_free_options;
                }
+       if (lu_opt_getchar(cfg,"MOUNT","private"))
+               captivefs_vfs->private=TRUE;
 
        if (captivefs_vfs->options.debug_messages)
                g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"captivefs_init");
index e5c9378..b59194f 100644 (file)
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 struct captivefs_vfs {
        CaptiveVfsObject *captive_vfs_object;
        struct captive_options options;
+       gboolean private;
        pid_t parent_pid;
        struct captivefs_vfs **global_ctx;
        gint inits,mounts;
index 3796168..aca3fd4 100644 (file)
@@ -106,13 +106,13 @@ filesystems in such case.
 This is the only option is interpreted by B<mount.@PACKAGE@> itself; it is not
 B<lufs-@PACKAGE@fs>(7) nor B<lufsd>(1) option.
 
-=item B<uid>=B<500>
-
-Supply the B<UID> to be the user identification number owning all the files.
+=item B<private>
 
-=item B<gid>=B<500>
-
-Supply the B<GID> to be the group identification number owning all the files.
+B<mount.captive>(8) defaults to filesystem files B<644> - read-write for system
+root (or the regular user owner) and read-only for others. You can force the
+mode B<600> by this option (read-write for the owner, inaccessible for others).
+Mode B<755> or <700> applies to directories. Options B<fmask>/B<dmask> will
+be OR-ed to the private/public permissions set by this option.
 
 =item B<fmask>=B<666>
 
@@ -123,6 +123,14 @@ Octal mask to be OR-ed on file permissions (minimum file permissions).
 Octal mask to be OR-ed on directory permissions (minimum directory
 permissions).
 
+=item B<uid>=B<500>
+
+Supply the B<UID> to be the user identification number owning all the files.
+
+=item B<gid>=B<500>
+
+Supply the B<GID> to be the group identification number owning all the files.
+
 =back
 
 =back