1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

s3-smb Use FILE_ATTRIBUTE_READONLY intead of aRONLY

This means we use just one constant for this file attribute.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 2011-04-29 11:36:14 +10:00
parent 9f75b7cbb3
commit 7f66ebde2e
10 changed files with 21 additions and 22 deletions

View File

@ -1405,7 +1405,7 @@ int cmd_setmode(void)
direct=0; direct=0;
break; break;
case 'r': case 'r':
attra[direct]|=aRONLY; attra[direct]|=FILE_ATTRIBUTE_READONLY;
break; break;
case 'h': case 'h':
attra[direct]|=aHIDDEN; attra[direct]|=aHIDDEN;

View File

@ -86,7 +86,6 @@ enum smb_read_errors {
#define DIR_STRUCT_SIZE 43 #define DIR_STRUCT_SIZE 43
/* these define the attribute byte as seen by DOS */ /* these define the attribute byte as seen by DOS */
#define aRONLY (1L<<0) /* 0x01 */
#define aHIDDEN (1L<<1) /* 0x02 */ #define aHIDDEN (1L<<1) /* 0x02 */
#define aSYSTEM (1L<<2) /* 0x04 */ #define aSYSTEM (1L<<2) /* 0x04 */
#define aVOLID (1L<<3) /* 0x08 */ #define aVOLID (1L<<3) /* 0x08 */

View File

@ -28,7 +28,7 @@
#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
/* for readability... */ /* for readability... */
#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0) #define IS_DOS_READONLY(test_mode) (((test_mode) & FILE_ATTRIBUTE_READONLY) != 0)
#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0) #define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0)
#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0) #define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0)
#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0) #define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0)

View File

@ -309,7 +309,7 @@ char *attrib_string(uint16 mode)
if (mode & aARCH) fstrcat(attrstr,"A"); if (mode & aARCH) fstrcat(attrstr,"A");
if (mode & aHIDDEN) fstrcat(attrstr,"H"); if (mode & aHIDDEN) fstrcat(attrstr,"H");
if (mode & aSYSTEM) fstrcat(attrstr,"S"); if (mode & aSYSTEM) fstrcat(attrstr,"S");
if (mode & aRONLY) fstrcat(attrstr,"R"); if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R");
return talloc_strdup(talloc_tos(), attrstr); return talloc_strdup(talloc_tos(), attrstr);
} }

View File

@ -1611,7 +1611,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
mode = 0; mode = 0;
if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY; if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= FILE_ATTRIBUTE_READONLY;
if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH; if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH;
if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM; if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM;
if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN; if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN;

View File

@ -1424,7 +1424,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode)
* Only allow delete on close for writable files. * Only allow delete on close for writable files.
*/ */
if ((dosmode & aRONLY) && if ((dosmode & FILE_ATTRIBUTE_READONLY) &&
!lp_delete_readonly(SNUM(fsp->conn))) { !lp_delete_readonly(SNUM(fsp->conn))) {
DEBUG(10,("can_set_delete_on_close: file %s delete on close " DEBUG(10,("can_set_delete_on_close: file %s delete on close "
"flag set but file attribute is readonly.\n", "flag set but file attribute is readonly.\n",

View File

@ -878,9 +878,9 @@ bool dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype)
/* Check the "must have" bits, which are the may have bits shifted eight */ /* Check the "must have" bits, which are the may have bits shifted eight */
/* If must have bit is set, the file/dir can not be returned in search unless the matching /* If must have bit is set, the file/dir can not be returned in search unless the matching
file attribute is set */ file attribute is set */
mask = ((dirtype >> 8) & (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM)); /* & 0x37 */ mask = ((dirtype >> 8) & (aDIR|aARCH|FILE_ATTRIBUTE_READONLY|aHIDDEN|aSYSTEM)); /* & 0x37 */
if(mask) { if(mask) {
if((mask & (mode & (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM))) == mask) /* check if matching attribute present */ if((mask & (mode & (aDIR|aARCH|FILE_ATTRIBUTE_READONLY|aHIDDEN|aSYSTEM))) == mask) /* check if matching attribute present */
return True; return True;
else else
return False; return False;

View File

@ -41,7 +41,7 @@ static int set_link_read_only_flag(const SMB_STRUCT_STAT *const sbuf)
#ifdef S_ISLNK #ifdef S_ISLNK
#if LINKS_READ_ONLY #if LINKS_READ_ONLY
if (S_ISLNK(sbuf->st_mode) && S_ISDIR(sbuf->st_mode)) if (S_ISLNK(sbuf->st_mode) && S_ISDIR(sbuf->st_mode))
return aRONLY; return FILE_ATTRIBUTE_READONLY;
#endif #endif
#endif #endif
return 0; return 0;
@ -173,12 +173,12 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn,
if (ro_opts == MAP_READONLY_YES) { if (ro_opts == MAP_READONLY_YES) {
/* Original Samba method - map inverse of user "w" bit. */ /* Original Samba method - map inverse of user "w" bit. */
if ((smb_fname->st.st_ex_mode & S_IWUSR) == 0) { if ((smb_fname->st.st_ex_mode & S_IWUSR) == 0) {
result |= aRONLY; result |= FILE_ATTRIBUTE_READONLY;
} }
} else if (ro_opts == MAP_READONLY_PERMISSIONS) { } else if (ro_opts == MAP_READONLY_PERMISSIONS) {
/* Check actual permissions for read-only. */ /* Check actual permissions for read-only. */
if (!can_write_to_file(conn, smb_fname)) { if (!can_write_to_file(conn, smb_fname)) {
result |= aRONLY; result |= FILE_ATTRIBUTE_READONLY;
} }
} /* Else never set the readonly bit. */ } /* Else never set the readonly bit. */
@ -192,14 +192,14 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn,
result |= aHIDDEN; result |= aHIDDEN;
if (S_ISDIR(smb_fname->st.st_ex_mode)) if (S_ISDIR(smb_fname->st.st_ex_mode))
result = aDIR | (result & aRONLY); result = aDIR | (result & FILE_ATTRIBUTE_READONLY);
result |= set_link_read_only_flag(&smb_fname->st); result |= set_link_read_only_flag(&smb_fname->st);
DEBUG(8,("dos_mode_from_sbuf returning ")); DEBUG(8,("dos_mode_from_sbuf returning "));
if (result & aHIDDEN) DEBUG(8, ("h")); if (result & aHIDDEN) DEBUG(8, ("h"));
if (result & aRONLY ) DEBUG(8, ("r")); if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
if (result & aSYSTEM) DEBUG(8, ("s")); if (result & aSYSTEM) DEBUG(8, ("s"));
if (result & aDIR ) DEBUG(8, ("d")); if (result & aDIR ) DEBUG(8, ("d"));
if (result & aARCH ) DEBUG(8, ("a")); if (result & aARCH ) DEBUG(8, ("a"));
@ -326,7 +326,7 @@ static bool get_ea_dos_attribute(connection_struct *conn,
DEBUG(8,("get_ea_dos_attribute returning (0x%x)", dosattr)); DEBUG(8,("get_ea_dos_attribute returning (0x%x)", dosattr));
if (dosattr & aHIDDEN) DEBUG(8, ("h")); if (dosattr & aHIDDEN) DEBUG(8, ("h"));
if (dosattr & aRONLY ) DEBUG(8, ("r")); if (dosattr & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
if (dosattr & aSYSTEM) DEBUG(8, ("s")); if (dosattr & aSYSTEM) DEBUG(8, ("s"));
if (dosattr & aDIR ) DEBUG(8, ("d")); if (dosattr & aDIR ) DEBUG(8, ("d"));
if (dosattr & aARCH ) DEBUG(8, ("a")); if (dosattr & aARCH ) DEBUG(8, ("a"));
@ -487,7 +487,7 @@ uint32 dos_mode_msdfs(connection_struct *conn,
DEBUG(8,("dos_mode_msdfs returning ")); DEBUG(8,("dos_mode_msdfs returning "));
if (result & aHIDDEN) DEBUG(8, ("h")); if (result & aHIDDEN) DEBUG(8, ("h"));
if (result & aRONLY ) DEBUG(8, ("r")); if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
if (result & aSYSTEM) DEBUG(8, ("s")); if (result & aSYSTEM) DEBUG(8, ("s"));
if (result & aDIR ) DEBUG(8, ("d")); if (result & aDIR ) DEBUG(8, ("d"));
if (result & aARCH ) DEBUG(8, ("a")); if (result & aARCH ) DEBUG(8, ("a"));
@ -511,7 +511,7 @@ int dos_attributes_to_stat_dos_flags(uint32_t dosmode)
dos_stat_flags |= UF_DOS_ARCHIVE; dos_stat_flags |= UF_DOS_ARCHIVE;
if (dosmode & aHIDDEN) if (dosmode & aHIDDEN)
dos_stat_flags |= UF_DOS_HIDDEN; dos_stat_flags |= UF_DOS_HIDDEN;
if (dosmode & aRONLY) if (dosmode & FILE_ATTRIBUTE_READONLY)
dos_stat_flags |= UF_DOS_RO; dos_stat_flags |= UF_DOS_RO;
if (dosmode & aSYSTEM) if (dosmode & aSYSTEM)
dos_stat_flags |= UF_DOS_SYSTEM; dos_stat_flags |= UF_DOS_SYSTEM;
@ -544,7 +544,7 @@ static bool get_stat_dos_flags(connection_struct *conn,
if (smb_fname->st.st_ex_flags & UF_DOS_HIDDEN) if (smb_fname->st.st_ex_flags & UF_DOS_HIDDEN)
*dosmode |= aHIDDEN; *dosmode |= aHIDDEN;
if (smb_fname->st.st_ex_flags & UF_DOS_RO) if (smb_fname->st.st_ex_flags & UF_DOS_RO)
*dosmode |= aRONLY; *dosmode |= FILE_ATTRIBUTE_READONLY;
if (smb_fname->st.st_ex_flags & UF_DOS_SYSTEM) if (smb_fname->st.st_ex_flags & UF_DOS_SYSTEM)
*dosmode |= aSYSTEM; *dosmode |= aSYSTEM;
if (smb_fname->st.st_ex_flags & UF_DOS_NOINDEX) if (smb_fname->st.st_ex_flags & UF_DOS_NOINDEX)
@ -672,7 +672,7 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
DEBUG(8,("dos_mode returning ")); DEBUG(8,("dos_mode returning "));
if (result & aHIDDEN) DEBUG(8, ("h")); if (result & aHIDDEN) DEBUG(8, ("h"));
if (result & aRONLY ) DEBUG(8, ("r")); if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
if (result & aSYSTEM) DEBUG(8, ("s")); if (result & aSYSTEM) DEBUG(8, ("s"));
if (result & aDIR ) DEBUG(8, ("d")); if (result & aDIR ) DEBUG(8, ("d"));
if (result & aARCH ) DEBUG(8, ("a")); if (result & aARCH ) DEBUG(8, ("a"));

View File

@ -1110,7 +1110,7 @@ void reply_getatr(struct smb_request *req)
if (*fname == '\0') { if (*fname == '\0') {
mode = aHIDDEN | aDIR; mode = aHIDDEN | aDIR;
if (!CAN_WRITE(conn)) { if (!CAN_WRITE(conn)) {
mode |= aRONLY; mode |= FILE_ATTRIBUTE_READONLY;
} }
size = 0; size = 0;
mtime = 0; mtime = 0;
@ -2449,10 +2449,10 @@ static NTSTATUS do_unlink(connection_struct *conn,
fattr = dos_mode(conn, smb_fname); fattr = dos_mode(conn, smb_fname);
if (dirtype & FILE_ATTRIBUTE_NORMAL) { if (dirtype & FILE_ATTRIBUTE_NORMAL) {
dirtype = aDIR|aARCH|aRONLY; dirtype = aDIR|aARCH|FILE_ATTRIBUTE_READONLY;
} }
dirtype &= (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM); dirtype &= (aDIR|aARCH|FILE_ATTRIBUTE_READONLY|aHIDDEN|aSYSTEM);
if (!dirtype) { if (!dirtype) {
return NT_STATUS_NO_SUCH_FILE; return NT_STATUS_NO_SUCH_FILE;
} }

View File

@ -4531,7 +4531,7 @@ static bool run_opentest(int dummy)
return False; return False;
} }
if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, aRONLY, 0))) { if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, FILE_ATTRIBUTE_READONLY, 0))) {
printf("cli_setatr failed (%s)\n", cli_errstr(cli1)); printf("cli_setatr failed (%s)\n", cli_errstr(cli1));
return False; return False;
} }