smbd/dosmode.c

ソースコードを見る。

関数

static int set_sparse_flag (const SMB_STRUCT_STAT *const sbuf)
static uint32 set_offline_flag (connection_struct *conn, const char *const path)
mode_t unix_mode (connection_struct *conn, int dosmode, const char *fname, const char *inherit_from_dir)
static uint32 dos_mode_from_sbuf (connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf)
static BOOL get_ea_dos_attribute (connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf, uint32 *pattr)
static BOOL set_ea_dos_attribute (connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf, uint32 dosmode)


関数

static int set_sparse_flag ( const SMB_STRUCT_STAT *const   sbuf  )  [static]

dosmode.c24 行で定義されています。

参照元 dos_mode_from_sbuf()set_ea_dos_attribute().

00025 {
00026 #if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
00027         if (sbuf->st_size > sbuf->st_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
00028                 return FILE_ATTRIBUTE_SPARSE;
00029         }
00030 #endif
00031         return 0;
00032 }

static uint32 set_offline_flag ( connection_struct conn,
const char *const   path 
) [static]

dosmode.c38 行で定義されています。

参照先 smb_Dir::conndmapi_file_flags()dmapi_have_session().

参照元 set_ea_dos_attribute().

00039 {
00040         if (ISDOT(path) || ISDOTDOT(path)) {
00041                 return 0;
00042         }
00043 
00044         if (!lp_dmapi_support(SNUM(conn)) || !dmapi_have_session()) {
00045                 return 0;
00046         }
00047 
00048         return dmapi_file_flags(path);
00049 }

mode_t unix_mode ( connection_struct conn,
int  dosmode,
const char *  fname,
const char *  inherit_from_dir 
)

dosmode.c74 行で定義されています。

参照先 smb_Dir::connerrnoresultstrerror().

参照元 create_default_mode()mkdir_internal()open_file_ntcreate()set_ea_dos_attribute().

00076 {
00077         mode_t result = (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH);
00078         mode_t dir_mode = 0; /* Mode of the inherit_from directory if
00079                               * inheriting. */
00080 
00081         if (!lp_store_dos_attributes(SNUM(conn)) && IS_DOS_READONLY(dosmode)) {
00082                 result &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
00083         }
00084 
00085         if (fname && (inherit_from_dir != NULL)
00086             && lp_inherit_perms(SNUM(conn))) {
00087                 SMB_STRUCT_STAT sbuf;
00088 
00089                 DEBUG(2, ("unix_mode(%s) inheriting from %s\n", fname,
00090                           inherit_from_dir));
00091                 if (SMB_VFS_STAT(conn, inherit_from_dir, &sbuf) != 0) {
00092                         DEBUG(4,("unix_mode(%s) failed, [dir %s]: %s\n", fname,
00093                                  inherit_from_dir, strerror(errno)));
00094                         return(0);      /* *** shouldn't happen! *** */
00095                 }
00096 
00097                 /* Save for later - but explicitly remove setuid bit for safety. */
00098                 dir_mode = sbuf.st_mode & ~S_ISUID;
00099                 DEBUG(2,("unix_mode(%s) inherit mode %o\n",fname,(int)dir_mode));
00100                 /* Clear "result" */
00101                 result = 0;
00102         } 
00103 
00104         if (IS_DOS_DIR(dosmode)) {
00105                 /* We never make directories read only for the owner as under DOS a user
00106                 can always create a file in a read-only directory. */
00107                 result |= (S_IFDIR | S_IWUSR);
00108 
00109                 if (dir_mode) {
00110                         /* Inherit mode of parent directory. */
00111                         result |= dir_mode;
00112                 } else {
00113                         /* Provisionally add all 'x' bits */
00114                         result |= (S_IXUSR | S_IXGRP | S_IXOTH);                 
00115 
00116                         /* Apply directory mask */
00117                         result &= lp_dir_mask(SNUM(conn));
00118                         /* Add in force bits */
00119                         result |= lp_force_dir_mode(SNUM(conn));
00120                 }
00121         } else { 
00122                 if (lp_map_archive(SNUM(conn)) && IS_DOS_ARCHIVE(dosmode))
00123                         result |= S_IXUSR;
00124 
00125                 if (lp_map_system(SNUM(conn)) && IS_DOS_SYSTEM(dosmode))
00126                         result |= S_IXGRP;
00127  
00128                 if (lp_map_hidden(SNUM(conn)) && IS_DOS_HIDDEN(dosmode))
00129                         result |= S_IXOTH;  
00130 
00131                 if (dir_mode) {
00132                         /* Inherit 666 component of parent directory mode */
00133                         result |= dir_mode & (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH);
00134                 } else {
00135                         /* Apply mode mask */
00136                         result &= lp_create_mask(SNUM(conn));
00137                         /* Add in force bits */
00138                         result |= lp_force_create_mode(SNUM(conn));
00139                 }
00140         }
00141 
00142         DEBUG(3,("unix_mode(%s) returning 0%o\n",fname,(int)result ));
00143         return(result);
00144 }

static uint32 dos_mode_from_sbuf ( connection_struct conn,
const char *  path,
SMB_STRUCT_STAT *  sbuf 
) [static]

dosmode.c150 行で定義されています。

参照先 can_write_to_file()smb_Dir::connMAP_READONLY_PERMISSIONSMAP_READONLY_YESresultset_sparse_flag().

参照元 set_ea_dos_attribute().

00151 {
00152         int result = 0;
00153         enum mapreadonly_options ro_opts = (enum mapreadonly_options)lp_map_readonly(SNUM(conn));
00154 
00155         if (ro_opts == MAP_READONLY_YES) {
00156                 /* Original Samba method - map inverse of user "w" bit. */
00157                 if ((sbuf->st_mode & S_IWUSR) == 0) {
00158                         result |= aRONLY;
00159                 }
00160         } else if (ro_opts == MAP_READONLY_PERMISSIONS) {
00161                 /* Check actual permissions for read-only. */
00162                 if (!can_write_to_file(conn, path, sbuf)) {
00163                         result |= aRONLY;
00164                 }
00165         } /* Else never set the readonly bit. */
00166 
00167         if (MAP_ARCHIVE(conn) && ((sbuf->st_mode & S_IXUSR) != 0))
00168                 result |= aARCH;
00169 
00170         if (MAP_SYSTEM(conn) && ((sbuf->st_mode & S_IXGRP) != 0))
00171                 result |= aSYSTEM;
00172         
00173         if (MAP_HIDDEN(conn) && ((sbuf->st_mode & S_IXOTH) != 0))
00174                 result |= aHIDDEN;   
00175   
00176         if (S_ISDIR(sbuf->st_mode))
00177                 result = aDIR | (result & aRONLY);
00178 
00179         result |= set_sparse_flag(sbuf);
00180  
00181 #ifdef S_ISLNK
00182 #if LINKS_READ_ONLY
00183         if (S_ISLNK(sbuf->st_mode) && S_ISDIR(sbuf->st_mode))
00184                 result |= aRONLY;
00185 #endif
00186 #endif
00187 
00188         DEBUG(8,("dos_mode_from_sbuf returning "));
00189 
00190         if (result & aHIDDEN) DEBUG(8, ("h"));
00191         if (result & aRONLY ) DEBUG(8, ("r"));
00192         if (result & aSYSTEM) DEBUG(8, ("s"));
00193         if (result & aDIR   ) DEBUG(8, ("d"));
00194         if (result & aARCH  ) DEBUG(8, ("a"));
00195         
00196         DEBUG(8,("\n"));
00197         return result;
00198 }

static BOOL get_ea_dos_attribute ( connection_struct conn,
const char *  path,
SMB_STRUCT_STAT *  sbuf,
uint32 *  pattr 
) [static]

dosmode.c204 行で定義されています。

参照先 smb_Dir::connerrnostrerror().

参照元 set_ea_dos_attribute().

00205 {
00206         ssize_t sizeret;
00207         fstring attrstr;
00208         unsigned int dosattr;
00209 
00210         if (!lp_store_dos_attributes(SNUM(conn))) {
00211                 return False;
00212         }
00213 
00214         /* Don't reset pattr to zero as we may already have filename-based attributes we
00215            need to preserve. */
00216 
00217         sizeret = SMB_VFS_GETXATTR(conn, path, SAMBA_XATTR_DOS_ATTRIB, attrstr, sizeof(attrstr));
00218         if (sizeret == -1) {
00219 #if defined(ENOTSUP) && defined(ENOATTR)
00220                 if ((errno != ENOTSUP) && (errno != ENOATTR) && (errno != EACCES) && (errno != EPERM)) {
00221                         DEBUG(1,("get_ea_dos_attributes: Cannot get attribute from EA on file %s: Error = %s\n",
00222                                 path, strerror(errno) ));
00223                         set_store_dos_attributes(SNUM(conn), False);
00224                 }
00225 #endif
00226                 return False;
00227         }
00228         /* Null terminate string. */
00229         attrstr[sizeret] = 0;
00230         DEBUG(10,("get_ea_dos_attribute: %s attrstr = %s\n", path, attrstr));
00231 
00232         if (sizeret < 2 || attrstr[0] != '0' || attrstr[1] != 'x' ||
00233                         sscanf(attrstr, "%x", &dosattr) != 1) {
00234                 DEBUG(1,("get_ea_dos_attributes: Badly formed DOSATTRIB on file %s - %s\n", path, attrstr));
00235                 return False;
00236         }
00237 
00238         if (S_ISDIR(sbuf->st_mode)) {
00239                 dosattr |= aDIR;
00240         }
00241         *pattr = (uint32)(dosattr & SAMBA_ATTRIBUTES_MASK);
00242 
00243         DEBUG(8,("get_ea_dos_attribute returning (0x%x)", dosattr));
00244 
00245         if (dosattr & aHIDDEN) DEBUG(8, ("h"));
00246         if (dosattr & aRONLY ) DEBUG(8, ("r"));
00247         if (dosattr & aSYSTEM) DEBUG(8, ("s"));
00248         if (dosattr & aDIR   ) DEBUG(8, ("d"));
00249         if (dosattr & aARCH  ) DEBUG(8, ("a"));
00250         
00251         DEBUG(8,("\n"));
00252 
00253         return True;
00254 }

static BOOL set_ea_dos_attribute ( connection_struct conn,
const char *  path,
SMB_STRUCT_STAT *  sbuf,
uint32  dosmode 
) [static]

dosmode.c260 行で定義されています。

参照先 become_root()can_write_to_file()close_file_fchmod()smb_Dir::conndos_mode_from_sbuf()endiferrnofd_handle::fdfiles_struct::fhget_acl_group_bits()get_ea_dos_attribute()notify_fname()null_timespec()open_file_fchmod()resultset_offline_flag()set_sparse_flag()snprintf()strerror()strrchr_m()unbecome_root()unix_mode().


Sambaに対してSat Aug 29 21:24:25 2009に生成されました。  doxygen 1.4.7