implemented attribute mapping and chmod. file attributes are mapped in
authorAndrew Tridgell <tridge@samba.org>
Tue, 6 Oct 1998 11:14:52 +0000 (11:14 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Oct 1998 11:14:52 +0000 (11:14 +0000)
the same manner as smbd. See the README for a full explanation.

source/smbwrapper/README
source/smbwrapper/smbw.c
source/smbwrapper/smbw.h
source/smbwrapper/smbw_stat.c

index e9a52fb2473676756e034ce16cf2999ea0856da2..9f18c3303631547f7bc0cceb95ebeead8bdacc4c 100644 (file)
@@ -30,7 +30,8 @@ happens. If you set SMBW_WORKGROUP to your workgroup or have workgroup
 set in yoru smb.conf then listing /smb/ should list all SMB servers in
 your workgroup.
 
-Environment variables
+
+ENVIRONMENT VARIABLES
 ---------------------
 
 SMBW_USER
@@ -58,6 +59,23 @@ SMBW_WORKGROUP
  /smb/ directory). It defaults to the one set in smb.conf.
 
 
+ATTRIBUTE MAPPING
+-----------------
+
+smbwrapper does an inverse attribute maping to what Samba does. This
+means that the archive bit appears as the user execute bit, the system
+bit appears as the group execute bit and the hidden bit appears as the
+other execute bit. You can control these with chmod. The mapping can
+be enabled an disabled using the normal smb.conf controls (ie. "map
+archive", "map system" and "map hidden").
+
+Read-only files appear as non-writeable by everyone. Writeable files
+appear as writeable by the current user.
+
+
+WHAT WORKS
+----------
+
 Things that I have tried and do seem to work include:
 
   emacs, tar, ls, cmp, cp, rsync, du, cat, rm, mv, less, more, wc, head,
index d6b377a0b50bf6d28eb7c7bae35a60a2c7db7ebf..ab2b807f6c6db0a8a4269098fb92bfedd351b2be 100644 (file)
@@ -1059,13 +1059,18 @@ int smbw_chmod(const char *fname, mode_t newmode)
                goto failed;
        }
 
-       if (!cli_getatr(&srv->cli, path, &mode, NULL, NULL)) {
+       mode = 0;
+
+       if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY;
+       if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH;
+       if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM;
+       if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN;
+
+       if (!cli_setatr(&srv->cli, path, mode, 0)) {
                errno = smbw_errno(&srv->cli);
                goto failed;
        }
        
-       /* assume success for the moment - need to add attribute mapping */
-
        smbw_busy--;
        return 0;
 
index 2f16efd216b8f68ba1ac587a7ec8bb2ae3bac323..43fb14bce07d9ab8d4e3d9efadaa6fb676757f19 100644 (file)
@@ -25,8 +25,8 @@
 #define SMBW_CLI_FD 512
 #define SMBW_MAX_OPEN 8192
 
-#define SMBW_FILE_MODE (S_IFREG | 0644)
-#define SMBW_DIR_MODE (S_IFDIR | 0755)
+#define SMBW_FILE_MODE (S_IFREG | 0444)
+#define SMBW_DIR_MODE (S_IFDIR | 0555)
 
 #define SMBW_PWD_ENV "PWD"
 
index ab351d56b1e5e8fb974db7859d314d1fa270e84c..a6d01f66d699017b5b46c31b85b92c81f6926a90 100644 (file)
@@ -33,6 +33,8 @@ setup basic info in a stat structure
 void smbw_setup_stat(struct stat *st, char *fname, size_t size, int mode)
 {
        ZERO_STRUCTP(st);
+       
+       st->st_mode = 0;
 
        if (IS_DOS_DIR(mode)) {
                st->st_mode = SMBW_DIR_MODE;
@@ -40,6 +42,11 @@ void smbw_setup_stat(struct stat *st, char *fname, size_t size, int mode)
                st->st_mode = SMBW_FILE_MODE;
        }
 
+       if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR;
+       if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP;
+       if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH;
+       if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR;
+
        st->st_size = size;
        st->st_blksize = 512;
        st->st_blocks = (size+511)/512;