diff options
author | Gerald Carter <jerry@samba.org> | 2006-01-24 03:54:33 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2006-01-24 03:54:33 +0000 |
commit | 4b9ea8812ef3f7612c41bf3aaab1371c981279cc (patch) | |
tree | 12df5cd6251aa0dbeb06f309ccf25b3096a08a14 /source | |
parent | 6de6cd120873b7879ec314299de1bcd5bf82c73d (diff) | |
download | samba-4b9ea8812ef3f7612c41bf3aaab1371c981279cc.tar.gz samba-4b9ea8812ef3f7612c41bf3aaab1371c981279cc.tar.xz samba-4b9ea8812ef3f7612c41bf3aaab1371c981279cc.zip |
r13105: pulling some code over for the 3.0.21b release....first take at it
Diffstat (limited to 'source')
92 files changed, 1401 insertions, 581 deletions
diff --git a/source/VERSION b/source/VERSION index a1d1b1090d2..36aca8bb1f3 100644 --- a/source/VERSION +++ b/source/VERSION @@ -1,6 +1,12 @@ ######################################################## # SAMBA Version # # # +# Samba versions are as follows # +# 3.0.x New production series # +# 3.0.x{pre,rc}y Preview/Testing & RC # +# 3.0.x[a-z] Patch releases # +# 3.0.x[a-z]-VENDOR-z Vendor patch releases # +# # # script/mkversion.sh # # will use this file to create # # include/version.h # @@ -31,7 +37,7 @@ SAMBA_VERSION_RELEASE=21 # e.g. SAMBA_VERSION_REVISION=a # # -> "2.2.8a" # ######################################################## -SAMBA_VERSION_REVISION=a +SAMBA_VERSION_REVISION=b ######################################################## # For 'pre' releases the version will be # @@ -91,3 +97,4 @@ SAMBA_VERSION_IS_SVN_SNAPSHOT= # -> "CVS 3.0.0rc2-VendorVersion" # ######################################################## SAMBA_VERSION_VENDOR_SUFFIX= +SAMBA_VENDOR_PATCH= diff --git a/source/client/clitar.c b/source/client/clitar.c index ad3387ffdda..5afe154cbbe 100644 --- a/source/client/clitar.c +++ b/source/client/clitar.c @@ -1097,6 +1097,8 @@ static void do_tarput(void) char *longfilename = NULL, linkflag; int skip = False; + ZERO_STRUCT(finfo); + GetTimeOfDay(&tp_start); DEBUG(5, ("RJS do_tarput called ...\n")); diff --git a/source/client/smbmount.c b/source/client/smbmount.c index 4438964b838..d8254ef23a7 100644 --- a/source/client/smbmount.c +++ b/source/client/smbmount.c @@ -386,6 +386,9 @@ static void send_fs_socket(char *the_service, char *mount_point, struct cli_stat c = NULL; if (!closed) { + /* close the name cache so that close_our_files() doesn't steal its FD */ + namecache_shutdown(); + /* redirect stdout & stderr since we can't know that the library functions we use are using DEBUG. */ if ( (fd = open("/dev/null", O_WRONLY)) < 0) diff --git a/source/include/includes.h b/source/include/includes.h index cde199eed8b..6342925877c 100644 --- a/source/include/includes.h +++ b/source/include/includes.h @@ -514,7 +514,7 @@ #include <langinfo.h> #endif -#ifdef HAVE_AIO_H +#if defined(HAVE_AIO_H) && defined(WITH_AIO) #include <aio.h> #endif @@ -565,6 +565,7 @@ typedef int VOLATILE SIG_ATOMIC_T; #endif #ifndef HAVE_SOCKLEN_T_TYPE +#define HAVE_SOCKLEN_T_TYPE typedef int socklen_t; #endif @@ -656,6 +657,20 @@ typedef int socklen_t; # endif #endif +#ifndef LARGE_SMB_DEV_T +# if (defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_DEV64_T)) || (defined(SIZEOF_DEV_T) && (SIZEOF_DEV_T == 8)) +# define LARGE_SMB_DEV_T 1 +# endif +#endif + +#ifdef LARGE_SMB_DEV_T +#define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32)) +#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(((SMB_BIG_UINT)(IVAL((p),(ofs))))| (((SMB_BIG_UINT)(IVAL((p),(ofs)+4))) << 32))) +#else +#define SDEV_T_VAL(p, ofs, v) (SIVAL((p),(ofs),v),SIVAL((p),(ofs)+4,0)) +#define DEV_T_VAL(p, ofs) ((SMB_DEV_T)(IVAL((p),(ofs)))) +#endif + /* * Setup the correctly sized inode type. */ @@ -675,9 +690,11 @@ typedef int socklen_t; #endif #ifdef LARGE_SMB_INO_T -#define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32)) +#define SINO_T_VAL(p, ofs, v) (SIVAL((p),(ofs),(v)&0xFFFFFFFF), SIVAL((p),(ofs)+4,(v)>>32)) +#define INO_T_VAL(p, ofs) ((SMB_INO_T)(((SMB_BIG_UINT)(IVAL(p,ofs)))| (((SMB_BIG_UINT)(IVAL(p,(ofs)+4))) << 32))) #else -#define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0)) +#define SINO_T_VAL(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0)) +#define INO_T_VAL(p, ofs) ((SMB_INO_T)(IVAL((p),(ofs)))) #endif #ifndef SMB_OFF_T diff --git a/source/include/ntdomain.h b/source/include/ntdomain.h index fd36006c0b7..a30b7243727 100644 --- a/source/include/ntdomain.h +++ b/source/include/ntdomain.h @@ -284,7 +284,7 @@ typedef struct pipes_struct { output_data out_data; - /* This context is used for PUD data and is freed between each pdu. + /* This context is used for PDU data and is freed between each pdu. Don't use for pipe state storage. */ TALLOC_CTX *mem_ctx; diff --git a/source/include/rpc_client.h b/source/include/rpc_client.h index 8a83c0f8ae8..0524f037e2c 100644 --- a/source/include/rpc_client.h +++ b/source/include/rpc_client.h @@ -23,8 +23,8 @@ /* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */ -#define CLI_DO_RPC( pcli, ctx, p_idx, opnum, q_in, r_out, \ - q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \ +#define CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \ + q_ps, r_ps, q_io_fn, r_io_fn, default_error, copy_sess_key ) \ {\ SMB_ASSERT(pcli->pipe_idx == p_idx); \ if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \ @@ -34,6 +34,7 @@ prs_mem_free( &q_ps );\ return NT_STATUS_NO_MEMORY;\ }\ + if ( copy_sess_key) prs_set_session_key(&q_ps, (const char *)pcli->dc->sess_key);\ if ( q_io_fn("", &q_in, &q_ps, 0) ) {\ NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \ if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\ @@ -41,6 +42,7 @@ prs_mem_free( &r_ps );\ return _smb_pipe_stat_;\ }\ + if ( copy_sess_key ) prs_set_session_key(&r_ps, (const char *)pcli->dc->sess_key);\ if (!r_io_fn("", &r_out, &r_ps, 0)) {\ prs_mem_free( &q_ps );\ prs_mem_free( &r_ps );\ @@ -55,6 +57,21 @@ prs_mem_free( &r_ps );\ } +#define CLI_DO_RPC_COPY_SESS_KEY( pcli, ctx, p_idx, opnum, q_in, r_out, \ + q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \ +{\ + CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \ + q_ps, r_ps, q_io_fn, r_io_fn, default_error, True ); \ +} + +#define CLI_DO_RPC( pcli, ctx, p_idx, opnum, q_in, r_out, \ + q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \ +{\ + CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \ + q_ps, r_ps, q_io_fn, r_io_fn, default_error, False ); \ +} + + /* Arrrgg. Same but with WERRORS. Needed for registry code. */ #define CLI_DO_RPC_WERR( pcli, ctx, p_idx, opnum, q_in, r_out, \ diff --git a/source/include/rpc_samr.h b/source/include/rpc_samr.h index 5555aaef0e4..342db37ea57 100644 --- a/source/include/rpc_samr.h +++ b/source/include/rpc_samr.h @@ -408,6 +408,7 @@ typedef struct sam_user_info_16 } SAM_USER_INFO_16; + /* SAM_USER_INFO_7 */ typedef struct sam_user_info_7 { @@ -417,6 +418,13 @@ typedef struct sam_user_info_7 } SAM_USER_INFO_7; +/* SAM_USER_INFO_9 */ +typedef struct sam_user_info_9 +{ + uint32 rid_group; /* Primary Group RID */ +} SAM_USER_INFO_9; + + /* SAMR_Q_CLOSE_HND - probably a policy handle close */ typedef struct q_samr_close_hnd_info { @@ -1255,6 +1263,7 @@ typedef struct sam_userinfo_ctr_info union { SAM_USER_INFO_7 *id7; + SAM_USER_INFO_9 *id9; SAM_USER_INFO_16 *id16; SAM_USER_INFO_17 *id17; SAM_USER_INFO_18 *id18; diff --git a/source/include/rpc_svcctl.h b/source/include/rpc_svcctl.h index 4a058999a38..8ca5e1772b8 100644 --- a/source/include/rpc_svcctl.h +++ b/source/include/rpc_svcctl.h @@ -27,8 +27,8 @@ #define SVCCTL_CLOSE_SERVICE 0x00 #define SVCCTL_CONTROL_SERVICE 0x01 #define SVCCTL_LOCK_SERVICE_DB 0x03 -#define SVCCTL_QUERY_SERVICE_SEC 0x04 /* not impmenented */ -#define SVCCTL_SET_SEVICE_SEC 0x05 /* not implemented */ +#define SVCCTL_QUERY_SERVICE_SEC 0x04 +#define SVCCTL_SET_SERVICE_SEC 0x05 #define SVCCTL_QUERY_STATUS 0x06 #define SVCCTL_UNLOCK_SERVICE_DB 0x08 #define SVCCTL_ENUM_DEPENDENT_SERVICES_W 0x0d @@ -385,5 +385,34 @@ typedef struct { WERROR status; } SVCCTL_R_UNLOCK_SERVICE_DB; + +/**************************/ + +typedef struct { + POLICY_HND handle; + uint32 security_flags; + uint32 buffer_size; +} SVCCTL_Q_QUERY_SERVICE_SEC; + +typedef struct { + RPC_BUFFER buffer; + uint32 needed; + WERROR status; +} SVCCTL_R_QUERY_SERVICE_SEC; + +/**************************/ + +typedef struct { + POLICY_HND handle; + uint32 security_flags; + RPC_BUFFER buffer; + uint32 buffer_size; +} SVCCTL_Q_SET_SERVICE_SEC; + +typedef struct { + WERROR status; +} SVCCTL_R_SET_SERVICE_SEC; + + #endif /* _RPC_SVCCTL_H */ diff --git a/source/include/smb.h b/source/include/smb.h index 6511f10365f..b6f471c1a6f 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -28,7 +28,7 @@ #define _SMB_H /* logged when starting the various Samba daemons */ -#define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2005" +#define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2006" #if defined(LARGE_SMB_OFF_T) @@ -655,9 +655,9 @@ struct share_mode_entry { struct process_id pid; uint16 op_mid; uint16 op_type; - uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */ - uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */ - uint32 private_options; /* NT Create options, but we only look at + uint32_t access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */ + uint32_t share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */ + uint32_t private_options; /* NT Create options, but we only look at * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB for * smbstatus and swat */ @@ -667,6 +667,25 @@ struct share_mode_entry { unsigned long share_file_id; }; +/* oplock break message definition - linearization of share_mode_entry. + +Offset Data length. +0 struct process_id pid 4 +4 uint16 op_mid 2 +6 uint16 op_type 2 +8 uint32 access_mask 4 +12 uint32 share_access 4 +16 uint32 private_options 4 +20 uint32 time sec 4 +24 uint32 time usec 4 +28 SMB_DEV_T dev 8 bytes. +36 SMB_INO_T inode 8 bytes +44 unsigned long file_id 4 bytes +48 + +*/ +#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 48 + struct share_mode_lock { const char *filename; SMB_DEV_T dev; @@ -1491,12 +1510,41 @@ struct inform_level2_message { unsigned long source_file_id; }; +/* kernel_oplock_message definition. + struct kernel_oplock_message { SMB_DEV_T dev; SMB_INO_T inode; unsigned long file_id; }; +Offset Data length. +0 SMB_DEV_T dev 8 bytes. +8 SMB_INO_T inode 8 bytes +16 unsigned long file_id 4 bytes +20 + +*/ +#define MSG_SMB_KERNEL_BREAK_SIZE 20 + +/* file_renamed_message definition. + +struct file_renamed_message { + SMB_DEV_T dev; + SMB_INO_T inode; + char names[1]; A variable area containing sharepath and filename. +}; + +Offset Data length. +0 SMB_DEV_T dev 8 bytes. +8 SMB_INO_T inode 8 bytes +16 char [] name zero terminated namelen bytes +minimum length == 18. + +*/ + +#define MSG_FILE_RENAMED_MIN_SIZE 16 + /* * On the wire return values for oplock types. */ @@ -1569,8 +1617,7 @@ struct node_status_extra { /* There really is more here ... */ }; -struct pwd_info -{ +struct pwd_info { BOOL null_pwd; BOOL cleartext; diff --git a/source/include/smb_macros.h b/source/include/smb_macros.h index 41eac7e9942..e1bed76f5be 100644 --- a/source/include/smb_macros.h +++ b/source/include/smb_macros.h @@ -24,6 +24,12 @@ #ifndef _SMB_MACROS_H #define _SMB_MACROS_H +/* no ops to help reduce the diff between the current 3.0 and release branch */ + +#define toupper_ascii(x) toupper(x) +#define tolower_ascii(x) tolower(x) + + /* Misc bit macros */ #define BOOLSTR(b) ((b) ? "Yes" : "No") #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0) diff --git a/source/lib/crc32.c b/source/lib/crc32.c index 7522ab7c811..a4ae90c4693 100644 --- a/source/lib/crc32.c +++ b/source/lib/crc32.c @@ -93,7 +93,7 @@ uint32 crc32_calc_buffer(const char *buf, size_t size) const unsigned char *p; uint32 crc; - p = buf; + p = (const unsigned char *)buf; crc = ~0U; while (size--) diff --git a/source/lib/gencache.c b/source/lib/gencache.c index 85599c92d33..fd44616270c 100644 --- a/source/lib/gencache.c +++ b/source/lib/gencache.c @@ -83,10 +83,13 @@ BOOL gencache_init(void) BOOL gencache_shutdown(void) { + int ret; /* tdb_close routine returns -1 on error */ if (!cache) return False; DEBUG(5, ("Closing cache file\n")); - return tdb_close(cache) != -1; + ret = tdb_close(cache); + cache = NULL; + return ret != -1; } diff --git a/source/lib/substitute.c b/source/lib/substitute.c index 4d22518230f..344f6e06fdf 100644 --- a/source/lib/substitute.c +++ b/source/lib/substitute.c @@ -448,6 +448,9 @@ void standard_sub_basic(const char *smb_name, char *str,size_t len) case 'v' : string_sub(p,"%v", SAMBA_VERSION_STRING,l); break; + case 'w' : + string_sub(p,"%w", lp_winbind_separator(),l); + break; case '$' : p += expand_env_var(p,l); break; /* Expand environment variables */ @@ -615,6 +618,9 @@ char *alloc_sub_basic(const char *smb_name, const char *str) case 'v' : t = realloc_string_sub(t, "%v", SAMBA_VERSION_STRING); break; + case 'w' : + t = realloc_string_sub(t, "%w", lp_winbind_separator()); + break; case '$' : t = realloc_expand_env_var(t, p); /* Expand environment variables */ break; diff --git a/source/lib/username.c b/source/lib/username.c index 1973a8c7c60..4dd5b5f7ce7 100644 --- a/source/lib/username.c +++ b/source/lib/username.c @@ -266,7 +266,8 @@ static struct passwd *Get_Pwnam_internals(const char *user, char *user2) /* Try as given, if username wasn't originally lowercase */ if(strcmp(user, user2) != 0) { - DEBUG(5,("Trying _Get_Pwnam(), username as given is %s\n", user)); + DEBUG(5,("Trying _Get_Pwnam(), username as given is %s\n", + user)); ret = getpwnam_alloc(user); if(ret) goto done; @@ -275,7 +276,8 @@ static struct passwd *Get_Pwnam_internals(const char *user, char *user2) /* Try as uppercase, if username wasn't originally uppercase */ strupper_m(user2); if(strcmp(user, user2) != 0) { - DEBUG(5,("Trying _Get_Pwnam(), username as uppercase is %s\n", user2)); + DEBUG(5,("Trying _Get_Pwnam(), username as uppercase is %s\n", + user2)); ret = getpwnam_alloc(user2); if(ret) goto done; @@ -283,11 +285,14 @@ static struct passwd *Get_Pwnam_internals(const char *user, char *user2) /* Try all combinations up to usernamelevel */ strlower_m(user2); - DEBUG(5,("Checking combinations of %d uppercase letters in %s\n", lp_usernamelevel(), user2)); - ret = uname_string_combinations(user2, getpwnam_alloc, lp_usernamelevel()); + DEBUG(5,("Checking combinations of %d uppercase letters in %s\n", + lp_usernamelevel(), user2)); + ret = uname_string_combinations(user2, getpwnam_alloc, + lp_usernamelevel()); done: - DEBUG(5,("Get_Pwnam_internals %s find user [%s]!\n",ret ? "did":"didn't", user)); + DEBUG(5,("Get_Pwnam_internals %s find user [%s]!\n",ret ? + "did":"didn't", user)); return ret; } @@ -402,7 +407,8 @@ static BOOL user_in_netgroup_list(const char *user, const char *ngname) Check if a user is in a winbind group. ****************************************************************************/ -static BOOL user_in_winbind_group_list(const char *user, const char *gname, BOOL *winbind_answered) +static BOOL user_in_winbind_group_list(const char *user, const char *gname, + BOOL *winbind_answered) { int i; gid_t gid, gid_low, gid_high; @@ -414,13 +420,14 @@ static BOOL user_in_winbind_group_list(const char *user, const char *gname, BOOL *winbind_answered = False; if ((gid = nametogid(gname)) == (gid_t)-1) { - DEBUG(0,("user_in_winbind_group_list: nametogid for group %s failed.\n", - gname )); + DEBUG(0,("user_in_winbind_group_list: nametogid for group %s " + "failed.\n", gname )); goto err; } if (!lp_idmap_gid(&gid_low, &gid_high)) { - DEBUG(4, ("winbind gid range not configured, therefore %s cannot be a winbind group\n", gname)); + DEBUG(4, ("winbind gid range not configured, therefore %s " + "cannot be a winbind group\n", gname)); goto err; } @@ -460,7 +467,8 @@ static BOOL user_in_winbind_group_list(const char *user, const char *gname, BOOL } else - DEBUG(10,("user_in_winbind_group_list: using cached user groups for [%s]\n", user)); + DEBUG(10,("user_in_winbind_group_list: using cached user " + "groups for [%s]\n", user)); if ( DEBUGLEVEL >= 10 ) { DEBUG(10,("user_in_winbind_group_list: using groups -- ")); @@ -470,8 +478,9 @@ static BOOL user_in_winbind_group_list(const char *user, const char *gname, BOOL } /* - * Now we have the gid list for this user - convert the gname - * to a gid_t via either winbind or the local UNIX lookup and do the comparison. + * Now we have the gid list for this user - convert the gname to a + * gid_t via either winbind or the local UNIX lookup and do the + * comparison. */ for (i = 0; i < num_groups; i++) { @@ -502,7 +511,8 @@ BOOL user_in_unix_group_list(const char *user,const char *gname) struct sys_userlist *user_list; struct sys_userlist *member; - DEBUG(10,("user_in_unix_group_list: checking user %s in group %s\n", user, gname)); + DEBUG(10,("user_in_unix_group_list: checking user %s in group %s\n", + user, gname)); /* * We need to check the users primary group as this @@ -511,20 +521,22 @@ BOOL user_in_unix_group_list(const char *user,const char *gname) if (pass) { if (strequal(gname,gidtoname(pass->pw_gid))) { - DEBUG(10,("user_in_unix_group_list: group %s is primary group.\n", gname )); + DEBUG(10,("user_in_unix_group_list: group %s is " + "primary group.\n", gname )); return True; } } user_list = get_users_in_group(gname); if (user_list == NULL) { - DEBUG(10,("user_in_unix_group_list: no such group %s\n", gname )); + DEBUG(10,("user_in_unix_group_list: no such group %s\n", + gname )); return False; } for (member = user_list; member; member = member->next) { - DEBUG(10,("user_in_unix_group_list: checking user %s against member %s\n", - user, member->unix_name )); + DEBUG(10,("user_in_unix_group_list: checking user %s against " + "member %s\n", user, member->unix_name )); if (strequal(member->unix_name,user)) { free_userlist(user_list); return(True); @@ -539,7 +551,8 @@ BOOL user_in_unix_group_list(const char *user,const char *gname) Check if a user is in a group list. Ask winbind first, then use UNIX. ****************************************************************************/ -BOOL user_in_group_list(const char *user, const char *gname, gid_t *groups, size_t n_groups) +BOOL user_in_group_list(const char *user, const char *gname, gid_t *groups, + size_t n_groups) { BOOL winbind_answered = False; BOOL ret; @@ -566,7 +579,8 @@ BOOL user_in_group_list(const char *user, const char *gname, gid_t *groups, size ret = user_in_unix_group_list(user, gname); if (ret) - DEBUG(10,("user_in_group_list: user |%s| is in group |%s|\n", user, gname)); + DEBUG(10,("user_in_group_list: user |%s| is in group |%s|\n", + user, gname)); return ret; } @@ -575,7 +589,8 @@ BOOL user_in_group_list(const char *user, const char *gname, gid_t *groups, size and netgroup lists. ****************************************************************************/ -BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_groups) +BOOL user_in_list(const char *user,const char **list, gid_t *groups, + size_t n_groups) { if (!list || !*list) return False; @@ -584,7 +599,8 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr while (*list) { - DEBUG(10,("user_in_list: checking user |%s| against |%s|\n", user, *list)); + DEBUG(10,("user_in_list: checking user |%s| against |%s|\n", + user, *list)); /* * Check raw username. @@ -604,7 +620,8 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr */ if(user_in_netgroup_list(user, *list +1)) return True; - if(user_in_group_list(user, *list +1, groups, n_groups)) + if(user_in_group_list(user, *list +1, groups, + n_groups)) return True; } else if (**list == '+') { @@ -612,7 +629,8 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr /* * Search UNIX list followed by netgroup. */ - if(user_in_group_list(user, *list +2, groups, n_groups)) + if(user_in_group_list(user, *list +2, groups, + n_groups)) return True; if(user_in_netgroup_list(user, *list +2)) return True; @@ -623,7 +641,8 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr * Just search UNIX list. */ - if(user_in_group_list(user, *list +1, groups, n_groups)) + if(user_in_group_list(user, *list +1, groups, + n_groups)) return True; } @@ -635,7 +654,8 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr */ if(user_in_netgroup_list(user, *list +2)) return True; - if(user_in_group_list(user, *list +2, groups, n_groups)) + if(user_in_group_list(user, *list +2, groups, + n_groups)) return True; } else { /* @@ -646,8 +666,8 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr } } else if (!name_is_local(*list)) { /* - * If user name did not match and token is not - * a unix group and the token has a winbind separator in the + * If user name did not match and token is not a unix + * group and the token has a winbind separator in the * name then see if it is a Windows group. */ @@ -657,31 +677,42 @@ BOOL user_in_list(const char *user,const char **list, gid_t *groups, size_t n_gr BOOL ret; fstring groupname, domain; - /* Parse a string of the form DOMAIN/user into a domain and a user */ + /* Parse a string of the form DOMAIN/user into a + * domain and a user */ char *p = strchr(*list,*lp_winbind_separator()); - DEBUG(10,("user_in_list: checking if user |%s| is in winbind group |%s|\n", user, *list)); + DEBUG(10,("user_in_list: checking if user |%s| is in " + "winbind group |%s|\n", user, *list)); if (p) { fstrcpy(groupname, p+1); fstrcpy(domain, *list); domain[PTR_DIFF(p, *list)] = 0; - /* Check to see if name is a Windows group; Win2k native mode DCs - will return domain local groups; while NT4 or mixed mode 2k DCs - will not */ + /* Check to see if name is a Windows group; + Win2k native mode DCs will return domain + local groups; while NT4 or mixed mode 2k + DCs will not */ - if ( winbind_lookup_name(domain, groupname, &g_sid, &name_type) + if ( winbind_lookup_name(domain, groupname, + &g_sid, &name_type) && ( name_type==SID_NAME_DOM_GRP || - (strequal(lp_workgroup(), domain) && name_type==SID_NAME_ALIAS) ) ) + (strequal(lp_workgroup(), domain) && + name_type==SID_NAME_ALIAS) ) ) { - /* Check if user name is in the Windows group */ - ret = user_in_winbind_group_list(user, *list, &winbind_answered); + /* Check if user name is in the + * Windows group */ + ret = user_in_winbind_group_list( + user, *list, + &winbind_answered); if (winbind_answered && ret == True) { - DEBUG(10,("user_in_list: user |%s| is in winbind group |%s|\n", user, *list)); + DEBUG(10,("user_in_list: user " + "|%s| is in winbind " + "group |%s|\n", + user, *list)); return ret; } } diff --git a/source/lib/util_file.c b/source/lib/util_file.c index 963d610beff..407a8b24fc9 100644 --- a/source/lib/util_file.c +++ b/source/lib/util_file.c @@ -525,7 +525,7 @@ static char **file_lines_parse(char *p, size_t size, int *numlines) char **file_lines_load(const char *fname, int *numlines) { char *p; - size_t size; + size_t size = 0; p = file_load(fname, &size); if (!p) { diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c index 6562dae952b..91c3305996e 100644 --- a/source/lib/util_sock.c +++ b/source/lib/util_sock.c @@ -181,6 +181,9 @@ static const smb_socket_option socket_options[] = { #ifdef SO_RCVTIMEO {"SO_RCVTIMEO", SOL_SOCKET, SO_RCVTIMEO, 0, OPT_INT}, #endif +#ifdef TCP_FASTACK + {"TCP_FASTACK", IPPROTO_TCP, TCP_FASTACK, 0, OPT_INT}, +#endif {NULL,0,0,0,0}}; /**************************************************************************** diff --git a/source/libads/ads_ldap.c b/source/libads/ads_ldap.c index ae86ef0b764..fea4cd0fd09 100644 --- a/source/libads/ads_ldap.c +++ b/source/libads/ads_ldap.c @@ -56,7 +56,7 @@ ADS_STATUS ads_sid_to_dn(ADS_STRUCT *ads, goto done; } - rc = ads_search_retry(ads, (void **)&msg, ldap_exp, attr); + rc = ads_search_retry(ads, (void **)(void *)&msg, ldap_exp, attr); if (!ADS_ERR_OK(rc)) { DEBUG(1,("ads_sid_to_dn ads_search: %s\n", ads_errstr(rc))); diff --git a/source/libads/ldap.c b/source/libads/ldap.c index 2123d5b55c5..dc93bd556c7 100644 --- a/source/libads/ldap.c +++ b/source/libads/ldap.c @@ -1165,7 +1165,7 @@ uint32 ads_get_kvno(ADS_STRUCT *ads, const char *machine_name) if (asprintf(&filter, "(samAccountName=%s$)", machine_name) == -1) { return kvno; } - ret = ads_search(ads, (void**) &res, filter, attrs); + ret = ads_search(ads, (void**)(void *)&res, filter, attrs); SAFE_FREE(filter); if (!ADS_ERR_OK(ret) && ads_count_replies(ads, res)) { DEBUG(1,("ads_get_kvno: Computer Account For %s not found.\n", machine_name)); @@ -1219,7 +1219,7 @@ ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machin ADS_STATUS ret = ADS_ERROR(LDAP_SUCCESS); char *dn_string = NULL; - ret = ads_find_machine_acct(ads, (void **)&res, machine_name); + ret = ads_find_machine_acct(ads, (void **)(void *)&res, machine_name); if (!ADS_ERR_OK(ret) || ads_count_replies(ads, res) != 1) { DEBUG(5,("ads_clear_service_principal_names: WARNING: Host Account for %s not found... skipping operation.\n", machine_name)); DEBUG(5,("ads_clear_service_principal_names: WARNING: Service Principals for %s have NOT been cleared.\n", machine_name)); @@ -1287,7 +1287,7 @@ ADS_STATUS ads_add_service_principal_name(ADS_STRUCT *ads, const char *machine_n char *dn_string = NULL; const char *servicePrincipalName[4] = {NULL, NULL, NULL, NULL}; - ret = ads_find_machine_acct(ads, (void **)&res, machine_name); + ret = ads_find_machine_acct(ads, (void **)(void *)&res, machine_name); if (!ADS_ERR_OK(ret) || ads_count_replies(ads, res) != 1) { DEBUG(1,("ads_add_service_principal_name: WARNING: Host Account for %s not found... skipping operation.\n", machine_name)); @@ -1401,7 +1401,7 @@ static ADS_STATUS ads_add_machine_acct(ADS_STRUCT *ads, const char *machine_name name_to_fqdn(my_fqdn, machine_name); - status = ads_find_machine_acct(ads, (void **)&res, machine_name); + status = ads_find_machine_acct(ads, (void **)(void *)&res, machine_name); if (ADS_ERR_OK(status) && ads_count_replies(ads, res) == 1) { char *dn_string = ads_get_dn(ads, res); if (!dn_string) { @@ -1774,7 +1774,7 @@ ADS_STATUS ads_join_realm(ADS_STRUCT *ads, const char *machine_name, return status; } - status = ads_find_machine_acct(ads, (void **)&res, machine); + status = ads_find_machine_acct(ads, (void **)(void *)&res, machine); if (!ADS_ERR_OK(status)) { DEBUG(0, ("ads_join_realm: Host account test failed for machine %s\n", machine)); SAFE_FREE(machine); @@ -1800,8 +1800,9 @@ ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname) char *hostnameDN, *host; int rc; LDAPControl ldap_control; - LDAPControl * pldap_control[] = {&ldap_control, 0}; + LDAPControl * pldap_control[2] = {NULL, NULL}; + pldap_control[0] = &ldap_control; memset(&ldap_control, 0, sizeof(LDAPControl)); ldap_control.ldctl_oid = (char *)LDAP_SERVER_TREE_DELETE_OID; diff --git a/source/libads/ldap_user.c b/source/libads/ldap_user.c index 56a0d8013b2..3ff6acc9e83 100644 --- a/source/libads/ldap_user.c +++ b/source/libads/ldap_user.c @@ -65,7 +65,7 @@ ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user, if (!(new_dn = talloc_asprintf(ctx, "cn=%s,%s,%s", name, container, ads->config.bind_path))) goto done; - if (!(controlstr = talloc_asprintf(ctx, "%u", UF_NORMAL_ACCOUNT))) + if (!(controlstr = talloc_asprintf(ctx, "%u", (UF_NORMAL_ACCOUNT | UF_ACCOUNTDISABLE)))) goto done; if (!(mods = ads_init_mods(ctx))) goto done; diff --git a/source/libsmb/clikrb5.c b/source/libsmb/clikrb5.c index 67e9f539adf..e0dcefeb1d7 100644 --- a/source/libsmb/clikrb5.c +++ b/source/libsmb/clikrb5.c @@ -456,6 +456,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, krb5_creds creds; krb5_data in_data; BOOL creds_ready = False; + int i = 0, maxtries = 3; retval = krb5_parse_name(context, principal, &server); if (retval) { @@ -479,7 +480,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, goto cleanup_creds; } - while(!creds_ready) { + while (!creds_ready && (i < maxtries)) { if ((retval = krb5_get_credentials(context, 0, ccache, &creds, &credsp))) { DEBUG(1,("ads_krb5_mk_req: krb5_get_credentials failed for %s (%s)\n", @@ -497,6 +498,8 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, if (!ads_cleanup_expired_creds(context, ccache, credsp)) creds_ready = True; + + i++; } DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s) is valid until: (%s - %u)\n", @@ -767,7 +770,6 @@ static krb5_enctype get_enctype_from_ap_req(krb5_ap_req *ap_req) static krb5_error_code get_key_from_keytab(krb5_context context, - krb5_keytab keytab, krb5_const_principal server, krb5_enctype enctype, krb5_kvno kvno, @@ -775,13 +777,18 @@ get_key_from_keytab(krb5_context context, { krb5_keytab_entry entry; krb5_error_code ret; - krb5_keytab real_keytab; + krb5_keytab keytab; char *name = NULL; - if (keytab == NULL) { - krb5_kt_default(context, &real_keytab); - } else { - real_keytab = keytab; + /* We have to open a new keytab handle here, as MIT does + an implicit open/getnext/close on krb5_kt_get_entry. We + may be in the middle of a keytab enumeration when this is + called. JRA. */ + + ret = krb5_kt_default(context, &keytab); + if (ret) { + DEBUG(0,("get_key_from_keytab: failed to open keytab: %s\n", error_message(ret))); + return ret; } if ( DEBUGLEVEL >= 10 ) { @@ -792,7 +799,7 @@ get_key_from_keytab(krb5_context context, } ret = krb5_kt_get_entry(context, - real_keytab, + keytab, server, kvno, enctype, @@ -819,10 +826,7 @@ get_key_from_keytab(krb5_context context, smb_krb5_kt_free_entry(context, &entry); out: - if (keytab == NULL) { - krb5_kt_close(context, real_keytab); - } - + krb5_kt_close(context, keytab); return ret; } @@ -913,7 +917,6 @@ krb5_error_code decode_krb5_ap_req(const krb5_data *code, krb5_ap_req **rep); } ret = get_key_from_keytab(context, - keytab, server, enctype, kvno, diff --git a/source/libsmb/clispnego.c b/source/libsmb/clispnego.c index 6340a9bdcd4..cc481a066ab 100644 --- a/source/libsmb/clispnego.c +++ b/source/libsmb/clispnego.c @@ -260,7 +260,7 @@ BOOL parse_negTokenTarg(DATA_BLOB blob, char *OIDs[ASN1_MAX_OIDS], DATA_BLOB *se /* generate a krb5 GSS-API wrapper packet given a ticket */ -DATA_BLOB spnego_gen_krb5_wrap(DATA_BLOB ticket, const uint8 tok_id[2]) +DATA_BLOB spnego_gen_krb5_wrap(const DATA_BLOB ticket, const uint8 tok_id[2]) { ASN1_DATA data; DATA_BLOB ret; diff --git a/source/libsmb/nmblib.c b/source/libsmb/nmblib.c index 164f85be7bf..4d84d7bc499 100644 --- a/source/libsmb/nmblib.c +++ b/source/libsmb/nmblib.c @@ -331,7 +331,7 @@ static int put_nmb_name(char *buf,int offset,struct nmb_name *name) Useful for debugging messages. ******************************************************************/ -char *nmb_namestr(struct nmb_name *n) +char *nmb_namestr(const struct nmb_name *n) { static int i=0; static fstring ret[4]; diff --git a/source/libsmb/ntlmssp.c b/source/libsmb/ntlmssp.c index 0becc7fdee3..c891ede9bb7 100644 --- a/source/libsmb/ntlmssp.c +++ b/source/libsmb/ntlmssp.c @@ -384,6 +384,11 @@ static void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state, void ntlmssp_weaken_keys(NTLMSSP_STATE *ntlmssp_state) { + /* Nothing to weaken. We certainly don't want to 'extend' the length... */ + if (ntlmssp_state->session_key.length < 8) { + return; + } + /* Key weakening not performed on the master key for NTLM2 and does not occour for NTLM1. Therefore we only need to do this for the LM_KEY. diff --git a/source/libsmb/ntlmssp_sign.c b/source/libsmb/ntlmssp_sign.c index e41cd6437c2..cc6323718b3 100644 --- a/source/libsmb/ntlmssp_sign.c +++ b/source/libsmb/ntlmssp_sign.c @@ -139,7 +139,7 @@ NTSTATUS ntlmssp_sign_packet(NTLMSSP_STATE *ntlmssp_state, { NTSTATUS nt_status; - if (!ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) { + if (!(ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN)) { DEBUG(3, ("NTLMSSP Signing not negotiated - cannot sign packet!\n")); return NT_STATUS_INVALID_PARAMETER; } @@ -238,7 +238,7 @@ NTSTATUS ntlmssp_seal_packet(NTLMSSP_STATE *ntlmssp_state, { NTSTATUS nt_status; - if (!ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) { + if (!(ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL)) { DEBUG(3, ("NTLMSSP Sealing not negotiated - cannot seal packet!\n")); return NT_STATUS_INVALID_PARAMETER; } diff --git a/source/libsmb/samlogon_cache.c b/source/libsmb/samlogon_cache.c index d0469a1a481..ef60055cf47 100644 --- a/source/libsmb/samlogon_cache.c +++ b/source/libsmb/samlogon_cache.c @@ -150,8 +150,12 @@ BOOL netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user ) prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); - if ( !prs_uint32( "timestamp", &ps, 0, (uint32*)&t ) ) - return False; + { + uint32 ts; + if ( !prs_uint32( "timestamp", &ps, 0, &ts ) ) + return False; + t = (time_t)ts; + } if ( net_io_user_info3("", user, &ps, 0, 3, 0) ) { diff --git a/source/libsmb/smbencrypt.c b/source/libsmb/smbencrypt.c index f99e48a0b9c..99f99f23f8c 100644 --- a/source/libsmb/smbencrypt.c +++ b/source/libsmb/smbencrypt.c @@ -542,7 +542,7 @@ void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *sessi for (i=0,k=0; i<in->length; i += 8, k += 7) { - uint8_t bin[8], bout[8], key[7]; + uint8 bin[8], bout[8], key[7]; memset(bin, 0, 8); memcpy(bin, &in->data[i], MIN(8, in->length-i)); diff --git a/source/modules/vfs_full_audit.c b/source/modules/vfs_full_audit.c index d9d898dc0ea..52e245a1763 100644 --- a/source/modules/vfs_full_audit.c +++ b/source/modules/vfs_full_audit.c @@ -35,6 +35,9 @@ * full_audit:success = open opendir * full_audit:failure = all * + * vfs op can be "all" which means log all operations. + * vfs op can be "none" which means no logging. + * * This leads to syslog entries of the form: * smbd_audit: nobody|192.168.234.1|opendir|ok|. * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt @@ -61,6 +64,11 @@ extern struct current_user current_user; static int vfs_full_audit_debug_level = DBGC_VFS; +struct vfs_full_audit_private_data { + struct bitmap *success_ops; + struct bitmap *failure_ops; +}; + #undef DBGC_CLASS #define DBGC_CLASS vfs_full_audit_debug_level @@ -662,24 +670,33 @@ static char *audit_prefix(connection_struct *conn) return prefix; } -static struct bitmap *success_ops = NULL; - -static BOOL log_success(vfs_op_type op) +static BOOL log_success(vfs_handle_struct *handle, vfs_op_type op) { - if (success_ops == NULL) + struct vfs_full_audit_private_data *pd = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, pd, + struct vfs_full_audit_private_data, + return True); + + if (pd->success_ops == NULL) { return True; + } - return bitmap_query(success_ops, op); + return bitmap_query(pd->success_ops, op); } -static struct bitmap *failure_ops = NULL; - -static BOOL log_failure(vfs_op_type op) +static BOOL log_failure(vfs_handle_struct *handle, vfs_op_type op) { - if (failure_ops == NULL) + struct vfs_full_audit_private_data *pd = NULL; + + SMB_VFS_HANDLE_GET_DATA(handle, pd, + struct vfs_full_audit_private_data, + return True); + + if (pd->failure_ops == NULL) return True; - return bitmap_query(failure_ops, op); + return bitmap_query(pd->failure_ops, op); } static void init_bitmap(struct bitmap **bm, const char **ops) @@ -706,6 +723,10 @@ static void init_bitmap(struct bitmap **bm, const char **ops) break; } + if (strequal(*ops, "none")) { + break; + } + for (i=0; i<SMB_VFS_OP_LAST; i++) { if (vfs_op_names[i].name == NULL) { smb_panic("vfs_full_audit.c: name table not " @@ -747,10 +768,10 @@ static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle, pstring op_msg; va_list ap; - if (success && (!log_success(op))) + if (success && (!log_success(handle, op))) return; - if (!success && (!log_failure(op))) + if (!success && (!log_failure(handle, op))) return; if (success) @@ -768,6 +789,22 @@ static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle, return; } +/* Free function for the private data. */ + +static void free_private_data(void **p_data) +{ + struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data; + + if (pd->success_ops) { + bitmap_free(pd->success_ops); + } + if (pd->failure_ops) { + bitmap_free(pd->failure_ops); + } + SAFE_FREE(pd); + *p_data = NULL; +} + /* Implementation of vfs_ops. Pass everything on to the default operation but log event first. */ @@ -775,18 +812,29 @@ static int smb_full_audit_connect(vfs_handle_struct *handle, connection_struct * const char *svc, const char *user) { int result; + struct vfs_full_audit_private_data *pd = NULL; const char *none[] = { NULL }; const char *all [] = { "all" }; + pd = SMB_MALLOC_P(struct vfs_full_audit_private_data); + if (!pd) { + return -1; + } + ZERO_STRUCTP(pd); + openlog("smbd_audit", 0, audit_syslog_facility(handle)); - init_bitmap(&success_ops, + init_bitmap(&pd->success_ops, lp_parm_string_list(SNUM(conn), "full_audit", "success", none)); - init_bitmap(&failure_ops, + init_bitmap(&pd->failure_ops, lp_parm_string_list(SNUM(conn), "full_audit", "failure", all)); + /* Store the private data. */ + SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data, + struct vfs_full_audit_private_data, return -1); + result = SMB_VFS_NEXT_CONNECT(handle, conn, svc, user); do_log(SMB_VFS_OP_CONNECT, True, handle, @@ -803,11 +851,8 @@ static void smb_full_audit_disconnect(vfs_handle_struct *handle, do_log(SMB_VFS_OP_DISCONNECT, True, handle, "%s", lp_servicename(SNUM(conn))); - bitmap_free(success_ops); - success_ops = NULL; - - bitmap_free(failure_ops); - failure_ops = NULL; + /* The bitmaps will be disconnected when the private + data is deleted. */ return; } @@ -2003,4 +2048,3 @@ NTSTATUS vfs_full_audit_init(void) return ret; } - diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index 01fdb8e74cf..e9d7f8d1851 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -657,13 +657,14 @@ static BOOL open_sockets(BOOL isdaemon, int port) pstring logfile; static BOOL opt_interactive; poptContext pc; + static char *p_lmhosts = dyn_LMHOSTSFILE; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon(default)" }, {"interactive", 'i', POPT_ARG_VAL, &opt_interactive, True, "Run interactive (not a daemon)" }, {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools & etc)" }, {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, - {"hosts", 'H', POPT_ARG_STRING, dyn_LMHOSTSFILE, 'H', "Load a netbios hosts file"}, + {"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, POPT_COMMON_SAMBA { NULL } @@ -773,7 +774,10 @@ static BOOL open_sockets(BOOL isdaemon, int port) pidfile_create("nmbd"); message_init(); message_register(MSG_FORCE_ELECTION, nmbd_message_election); +#if 0 + /* Until winsrepl is done. */ message_register(MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry); +#endif message_register(MSG_SHUTDOWN, nmbd_terminate); message_register(MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services); message_register(MSG_SEND_PACKET, msg_nmbd_send_packet); @@ -798,8 +802,8 @@ static BOOL open_sockets(BOOL isdaemon, int port) } /* Load in any static local names. */ - load_lmhosts_file(dyn_LMHOSTSFILE); - DEBUG(3,("Loaded hosts file %s\n", dyn_LMHOSTSFILE)); + load_lmhosts_file(p_lmhosts); + DEBUG(3,("Loaded hosts file %s\n", p_lmhosts)); /* If we are acting as a WINS server, initialise data structures. */ if( !initialise_wins() ) { diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c index aae76e44238..f3819b6f519 100644 --- a/source/nsswitch/wbinfo.c +++ b/source/nsswitch/wbinfo.c @@ -45,7 +45,7 @@ static char winbind_separator_int(BOOL strict) if (winbindd_request_response(WINBINDD_INFO, NULL, &response) != NSS_STATUS_SUCCESS) { - d_printf("could not obtain winbind separator!\n"); + d_fprintf(stderr, "could not obtain winbind separator!\n"); if (strict) { return -1; } @@ -57,7 +57,7 @@ static char winbind_separator_int(BOOL strict) got_sep = True; if (!sep) { - d_printf("winbind separator was NULL!\n"); + d_fprintf(stderr, "winbind separator was NULL!\n"); if (strict) { return -1; } @@ -84,7 +84,7 @@ static const char *get_winbind_domain(void) if (winbindd_request_response(WINBINDD_DOMAIN_NAME, NULL, &response) != NSS_STATUS_SUCCESS) { - d_printf("could not obtain winbind domain name!\n"); + d_fprintf(stderr, "could not obtain winbind domain name!\n"); /* HACK: (this module should not call lp_ funtions) */ return lp_workgroup(); @@ -199,7 +199,7 @@ static BOOL wbinfo_get_userdomgroups(const char *user_sid) return False; if (response.data.num_entries != 0) - printf("%s", (char *)response.extra_data); + d_printf("%s", (char *)response.extra_data); SAFE_FREE(response.extra_data); @@ -227,7 +227,7 @@ static BOOL wbinfo_wins_byname(char *name) /* Display response */ - printf("%s\n", response.data.winsresp); + d_printf("%s\n", response.data.winsresp); return True; } @@ -253,7 +253,7 @@ static BOOL wbinfo_wins_byip(char *ip) /* Display response */ - printf("%s\n", response.data.winsresp); + d_printf("%s\n", response.data.winsresp); return True; } @@ -282,7 +282,7 @@ static BOOL wbinfo_list_domains(void) while(next_token(&extra_data, name, "\n", sizeof(fstring))) { p = strchr(name, '\\'); if (p == 0) { - d_printf("Got invalid response: %s\n", + d_fprintf(stderr, "Got invalid response: %s\n", extra_data); return False; } @@ -379,7 +379,7 @@ static BOOL wbinfo_getdcname(const char *domain_name) if (winbindd_request_response(WINBINDD_GETDCNAME, &request, &response) != NSS_STATUS_SUCCESS) { - d_printf("Could not get dc name for %s\n", domain_name); + d_fprintf(stderr, "Could not get dc name for %s\n", domain_name); return False; } @@ -405,7 +405,7 @@ static BOOL wbinfo_check_secret(void) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (result != NSS_STATUS_SUCCESS) - d_printf("error code was %s (0x%x)\n", + d_fprintf(stderr, "error code was %s (0x%x)\n", response.data.auth.nt_status_string, response.data.auth.nt_status); @@ -607,7 +607,7 @@ static BOOL wbinfo_auth(char *username) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (response.data.auth.nt_status) - d_printf("error code was %s (0x%x)\nerror messsage was: %s\n", + d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", response.data.auth.nt_status_string, response.data.auth.nt_status, response.data.auth.error_string); @@ -707,7 +707,7 @@ static BOOL wbinfo_auth_crap(char *username) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (response.data.auth.nt_status) - d_printf("error code was %s (0x%x)\nerror messsage was: %s\n", + d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", response.data.auth.nt_status_string, response.data.auth.nt_status, response.data.auth.error_string); @@ -751,7 +751,7 @@ static BOOL wbinfo_klog(char *username) (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed"); if (response.data.auth.nt_status) - d_printf("error code was %s (0x%x)\nerror messsage was: %s\n", + d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", response.data.auth.nt_status_string, response.data.auth.nt_status, response.data.auth.error_string); @@ -760,12 +760,12 @@ static BOOL wbinfo_klog(char *username) return False; if (response.extra_data == NULL) { - d_printf("Did not get token data\n"); + d_fprintf(stderr, "Did not get token data\n"); return False; } if (!afs_settoken_str((char *)response.extra_data)) { - d_printf("Could not set token\n"); + d_fprintf(stderr, "Could not set token\n"); return False; } @@ -1022,6 +1022,7 @@ int main(int argc, char **argv) }; /* Samba client initialisation */ + load_case_tables(); if (!lp_load(dyn_CONFIGFILE, True, False, False)) { d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n", @@ -1058,114 +1059,114 @@ int main(int argc, char **argv) switch (opt) { case 'u': if (!print_domain_users(opt_domain_name)) { - d_printf("Error looking up domain users\n"); + d_fprintf(stderr, "Error looking up domain users\n"); goto done; } break; case 'g': if (!print_domain_groups(opt_domain_name)) { - d_printf("Error looking up domain groups\n"); + d_fprintf(stderr, "Error looking up domain groups\n"); goto done; } break; case 's': if (!wbinfo_lookupsid(string_arg)) { - d_printf("Could not lookup sid %s\n", string_arg); + d_fprintf(stderr, "Could not lookup sid %s\n", string_arg); goto done; } break; case 'n': if (!wbinfo_lookupname(string_arg)) { - d_printf("Could not lookup name %s\n", string_arg); + d_fprintf(stderr, "Could not lookup name %s\n", string_arg); goto done; } break; case 'N': if (!wbinfo_wins_byname(string_arg)) { - d_printf("Could not lookup WINS by name %s\n", string_arg); + d_fprintf(stderr, "Could not lookup WINS by name %s\n", string_arg); goto done; } break; case 'I': if (!wbinfo_wins_byip(string_arg)) { - d_printf("Could not lookup WINS by IP %s\n", string_arg); + d_fprintf(stderr, "Could not lookup WINS by IP %s\n", string_arg); goto done; } break; case 'U': if (!wbinfo_uid_to_sid(int_arg)) { - d_printf("Could not convert uid %d to sid\n", int_arg); + d_fprintf(stderr, "Could not convert uid %d to sid\n", int_arg); goto done; } break; case 'G': if (!wbinfo_gid_to_sid(int_arg)) { - d_printf("Could not convert gid %d to sid\n", + d_fprintf(stderr, "Could not convert gid %d to sid\n", int_arg); goto done; } break; case 'S': if (!wbinfo_sid_to_uid(string_arg)) { - d_printf("Could not convert sid %s to uid\n", + d_fprintf(stderr, "Could not convert sid %s to uid\n", string_arg); goto done; } break; case 'Y': if (!wbinfo_sid_to_gid(string_arg)) { - d_printf("Could not convert sid %s to gid\n", + d_fprintf(stderr, "Could not convert sid %s to gid\n", string_arg); goto done; } break; case 'A': if (!wbinfo_allocate_rid()) { - d_printf("Could not allocate a RID\n"); + d_fprintf(stderr, "Could not allocate a RID\n"); goto done; } break; case 't': if (!wbinfo_check_secret()) { - d_printf("Could not check secret\n"); + d_fprintf(stderr, "Could not check secret\n"); goto done; } break; case 'm': if (!wbinfo_list_domains()) { - d_printf("Could not list trusted domains\n"); + d_fprintf(stderr, "Could not list trusted domains\n"); goto done; } break; case OPT_SEQUENCE: if (!wbinfo_show_sequence(opt_domain_name)) { - d_printf("Could not show sequence numbers\n"); + d_fprintf(stderr, "Could not show sequence numbers\n"); goto done; } break; case 'D': if (!wbinfo_domain_info(string_arg)) { - d_printf("Could not get domain info\n"); + d_fprintf(stderr, "Could not get domain info\n"); goto done; } break; case 'r': if (!wbinfo_get_usergroups(string_arg)) { - d_printf("Could not get groups for user %s\n", + d_fprintf(stderr, "Could not get groups for user %s\n", string_arg); goto done; } break; case OPT_USERSIDS: if (!wbinfo_get_usersids(string_arg)) { - d_printf("Could not get group SIDs for user SID %s\n", + d_fprintf(stderr, "Could not get group SIDs for user SID %s\n", string_arg); goto done; } break; case OPT_USERDOMGROUPS: if (!wbinfo_get_userdomgroups(string_arg)) { - d_printf("Could not get user's domain groups " + d_fprintf(stderr, "Could not get user's domain groups " "for user SID %s\n", string_arg); goto done; } @@ -1174,13 +1175,13 @@ int main(int argc, char **argv) BOOL got_error = False; if (!wbinfo_auth(string_arg)) { - d_printf("Could not authenticate user %s with " + d_fprintf(stderr, "Could not authenticate user %s with " "plaintext password\n", string_arg); got_error = True; } if (!wbinfo_auth_crap(string_arg)) { - d_printf("Could not authenticate user %s with " + d_fprintf(stderr, "Could not authenticate user %s with " "challenge/response\n", string_arg); got_error = True; } @@ -1191,29 +1192,37 @@ int main(int argc, char **argv) } case 'k': if (!wbinfo_klog(string_arg)) { - d_printf("Could not klog user\n"); + d_fprintf(stderr, "Could not klog user\n"); goto done; } break; case 'p': if (!wbinfo_ping()) { - d_printf("could not ping winbindd!\n"); + d_fprintf(stderr, "Could not ping winbindd!\n"); goto done; } break; case OPT_SET_AUTH_USER: - wbinfo_set_auth_user(string_arg); + if (!wbinfo_set_auth_user(string_arg)) { + goto done; + } break; case OPT_GET_AUTH_USER: wbinfo_get_auth_user(); break; case OPT_GETDCNAME: - wbinfo_getdcname(string_arg); + if (!wbinfo_getdcname(string_arg)) { + goto done; + } break; - case OPT_SEPARATOR: - d_printf("%c\n", winbind_separator_int(True)); + case OPT_SEPARATOR: { + const char sep = winbind_separator_int(True); + if (sep == -1) { + goto done; + } + d_printf("%c\n", sep); break; - + } /* generic configuration options */ case OPT_DOMAIN_NAME: break; diff --git a/source/nsswitch/winbind_nss_config.h b/source/nsswitch/winbind_nss_config.h index 77d1dbe26e0..a3243b99e30 100644 --- a/source/nsswitch/winbind_nss_config.h +++ b/source/nsswitch/winbind_nss_config.h @@ -139,4 +139,8 @@ typedef int BOOL; #define S_ISSOCK(mode) ((mode & S_IFSOCK) == S_IFSOCK) #endif +#ifndef HAVE_SOCKLEN_T_TYPE +typedef int socklen_t; +#endif + #endif diff --git a/source/nsswitch/winbind_nss_solaris.c b/source/nsswitch/winbind_nss_solaris.c index 8076c043e04..b94b444fb4c 100644 --- a/source/nsswitch/winbind_nss_solaris.c +++ b/source/nsswitch/winbind_nss_solaris.c @@ -25,6 +25,8 @@ Boston, MA 02111-1307, USA. */ +#undef DEVELOPER + #include <stdlib.h> #include <sys/types.h> #include <sys/param.h> diff --git a/source/nsswitch/winbindd_pam.c b/source/nsswitch/winbindd_pam.c index e683f397b66..5f1d37751df 100644 --- a/source/nsswitch/winbindd_pam.c +++ b/source/nsswitch/winbindd_pam.c @@ -634,7 +634,8 @@ enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain, contact_domain->dcname, name_user, name_domain, - global_myname(), + /* Bug #3248 - found by Stefan Burkei. */ + workstation, /* We carefully set this above so use it... */ state->request.data.auth_crap.chal, lm_resp, nt_resp, diff --git a/source/param/loadparm.c b/source/param/loadparm.c index cdef0340618..526bce9b60e 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -2532,7 +2532,7 @@ BOOL lp_add_home(const char *pszHomename, int iDefaultService, string_set(&ServicePtrs[i]->comment, comment); } - /* set the browseable flag from the gloabl default */ + /* set the browseable flag from the global default */ ServicePtrs[i]->bBrowseable = sDefault.bBrowseable; @@ -4098,6 +4098,28 @@ static void lp_save_defaults(void) Set the server type we will announce as via nmbd. ********************************************************************/ +static const struct srv_role_tab { + uint32 role; + const char *role_str; +} srv_role_tab [] = { + { ROLE_STANDALONE, "ROLE_STANDALONE" }, + { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" }, + { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" }, + { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" }, + { 0, NULL } +}; + +const char* server_role_str(uint32 role) +{ + int i = 0; + for (i=0; srv_role_tab[i].role_str; i++) { + if (role == srv_role_tab[i].role) { + return srv_role_tab[i].role_str; + } + } + return NULL; +} + static void set_server_role(void) { server_role = ROLE_STANDALONE; @@ -4141,22 +4163,7 @@ static void set_server_role(void) break; } - DEBUG(10, ("set_server_role: role = ")); - - switch(server_role) { - case ROLE_STANDALONE: - DEBUGADD(10, ("ROLE_STANDALONE\n")); - break; - case ROLE_DOMAIN_MEMBER: - DEBUGADD(10, ("ROLE_DOMAIN_MEMBER\n")); - break; - case ROLE_DOMAIN_BDC: - DEBUGADD(10, ("ROLE_DOMAIN_BDC\n")); - break; - case ROLE_DOMAIN_PDC: - DEBUGADD(10, ("ROLE_DOMAIN_PDC\n")); - break; - } + DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role))); } /*********************************************************** diff --git a/source/passdb/passdb.c b/source/passdb/passdb.c index e073db3499c..20aa4e04f2f 100644 --- a/source/passdb/passdb.c +++ b/source/passdb/passdb.c @@ -2383,13 +2383,16 @@ BOOL pdb_increment_bad_password_count(SAM_ACCOUNT *sampass) { uint32 account_policy_lockout; BOOL autolock_updated = False, badpw_updated = False; + BOOL ret; if (!sampass) return False; /* Retrieve the account lockout policy */ - if (!pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, - &account_policy_lockout)) { + become_root(); + ret = pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_lockout); + unbecome_root(); + if ( !ret ) { DEBUG(0, ("pdb_increment_bad_password_count: pdb_get_account_policy failed.\n")); return False; } diff --git a/source/passdb/pdb_sql.c b/source/passdb/pdb_sql.c index f52888bfa91..f4f6e0112ae 100644 --- a/source/passdb/pdb_sql.c +++ b/source/passdb/pdb_sql.c @@ -536,13 +536,12 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const if (query->update) { query->part1[strlen(query->part1) - 1] = '\0'; - query->part1 = - talloc_asprintf_append(query->part1, - " WHERE %s = '%s'", - config_value_read(location, - "user sid column", - CONFIG_USER_SID_DEFAULT), - sid_to_string(sid_str, pdb_get_user_sid (newpwd))); + query->part1 = talloc_asprintf( + mem_ctx, "%s WHERE %s = '%s'", query->part1, + config_value_read(location, + "user sid column", + CONFIG_USER_SID_DEFAULT), + sid_to_string(sid_str, pdb_get_user_sid (newpwd))); } else { query->part2[strlen(query->part2) - 1] = ')'; query->part1[strlen(query->part1) - 1] = ')'; diff --git a/source/passdb/secrets.c b/source/passdb/secrets.c index 35ccb2c725b..c173a5ea868 100644 --- a/source/passdb/secrets.c +++ b/source/passdb/secrets.c @@ -138,7 +138,7 @@ BOOL secrets_fetch_domain_sid(const char *domain, DOM_SID *sid) { DOM_SID *dyn_sid; fstring key; - size_t size; + size_t size = 0; slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_SID, domain); strupper_m(key); @@ -147,8 +147,7 @@ BOOL secrets_fetch_domain_sid(const char *domain, DOM_SID *sid) if (dyn_sid == NULL) return False; - if (size != sizeof(DOM_SID)) - { + if (size != sizeof(DOM_SID)) { SAFE_FREE(dyn_sid); return False; } @@ -171,7 +170,7 @@ BOOL secrets_fetch_domain_guid(const char *domain, struct uuid *guid) { struct uuid *dyn_guid; fstring key; - size_t size; + size_t size = 0; struct uuid new_guid; slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain); @@ -187,8 +186,7 @@ BOOL secrets_fetch_domain_guid(const char *domain, struct uuid *guid) return False; } - if (size != sizeof(struct uuid)) - { + if (size != sizeof(struct uuid)) { DEBUG(1,("UUID size %d is wrong!\n", (int)size)); SAFE_FREE(dyn_guid); return False; @@ -276,7 +274,7 @@ BOOL secrets_fetch_trust_account_password(const char *domain, uint8 ret_pwd[16], { struct machine_acct_pass *pass; char *plaintext; - size_t size; + size_t size = 0; plaintext = secrets_fetch_machine_password(domain, pass_last_set_time, channel); @@ -326,7 +324,7 @@ BOOL secrets_fetch_trusted_domain_password(const char *domain, char** pwd, DOM_SID *sid, time_t *pass_last_set_time) { struct trusted_dom_pass pass; - size_t size; + size_t size = 0; /* unpacking structures */ char* pass_buf; @@ -361,7 +359,7 @@ BOOL secrets_fetch_trusted_domain_password(const char *domain, char** pwd, if (pass_last_set_time) *pass_last_set_time = pass.mod_time; /* domain sid */ - sid_copy(sid, &pass.domain_sid); + if (sid != NULL) sid_copy(sid, &pass.domain_sid); return True; } @@ -599,7 +597,7 @@ BOOL secrets_store_ldap_pw(const char* dn, char* pw) BOOL fetch_ldap_pw(char **dn, char** pw) { char *key = NULL; - size_t size; + size_t size = 0; *dn = smb_xstrdup(lp_ldap_admin_dn()); @@ -682,7 +680,7 @@ NTSTATUS secrets_get_trusted_domains(TALLOC_CTX* ctx, int* enum_ctx, unsigned in char *pattern; unsigned int start_idx; uint32 idx = 0; - size_t size, packed_size = 0; + size_t size = 0, packed_size = 0; fstring dom_name; char *packed_pass; struct trusted_dom_pass *pass = TALLOC_ZERO_P(ctx, struct trusted_dom_pass); @@ -877,7 +875,7 @@ BOOL secrets_fetch_afs_key(const char *cell, struct afs_key *result) { fstring key; struct afs_keyfile *keyfile; - size_t size; + size_t size = 0; uint32 i; slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_AFS_KEYFILE, cell); diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index 09775e60c8c..3649da1ac05 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -3279,6 +3279,8 @@ WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key ) TALLOC_FREE( data ); + p2->data = NULL; + DEBUG(8,("delete_all_printer_data: Removed all Printer Data from printer [%s]\n", p2->printername )); diff --git a/source/profile/profile.c b/source/profile/profile.c index 0cf8c8e15bf..838383b1afe 100644 --- a/source/profile/profile.c +++ b/source/profile/profile.c @@ -44,7 +44,7 @@ struct timeval profile_endtime_nested; /**************************************************************************** receive a set profile level message ****************************************************************************/ -void profile_message(int msg_type, pid_t src, void *buf, size_t len) +void profile_message(int msg_type, struct process_id src, void *buf, size_t len) { int level; @@ -54,21 +54,25 @@ void profile_message(int msg_type, pid_t src, void *buf, size_t len) case 0: /* turn off profiling */ do_profile_flag = False; do_profile_times = False; - DEBUG(1,("INFO: Profiling turned OFF from pid %d\n", (int)src)); + DEBUG(1,("INFO: Profiling turned OFF from pid %d\n", + (int)procid_to_pid(&src))); break; case 1: /* turn on counter profiling only */ do_profile_flag = True; do_profile_times = False; - DEBUG(1,("INFO: Profiling counts turned ON from pid %d\n", (int)src)); + DEBUG(1,("INFO: Profiling counts turned ON from pid %d\n", + (int)procid_to_pid(&src))); break; case 2: /* turn on complete profiling */ do_profile_flag = True; do_profile_times = True; - DEBUG(1,("INFO: Full profiling turned ON from pid %d\n", (int)src)); + DEBUG(1,("INFO: Full profiling turned ON from pid %d\n", + (int)procid_to_pid(&src))); break; case 3: /* reset profile values */ memset((char *)profile_p, 0, sizeof(*profile_p)); - DEBUG(1,("INFO: Profiling values cleared from pid %d\n", (int)src)); + DEBUG(1,("INFO: Profiling values cleared from pid %d\n", + (int)procid_to_pid(&src))); break; } #else /* WITH_PROFILE */ diff --git a/source/python/setup.py b/source/python/setup.py index 18f1f2648ab..ffdafd70877 100755 --- a/source/python/setup.py +++ b/source/python/setup.py @@ -63,8 +63,10 @@ for lib in string.split(samba_libs): next_is_flag = 0; elif lib == "-Wl,-rpath": next_is_path = 1; - elif lib[0:2] in ("-l","-pthread"): + elif lib[0:2] in ("-l"): libraries.append(lib[2:]) + elif lib[0:8] in ("-pthread"): + pass # Skip linker flags elif lib[0:2] == "-L": library_dirs.append(lib[2:]) elif lib[0:2] in ("-W","-s"): diff --git a/source/rpc_client/cli_netlogon.c b/source/rpc_client/cli_netlogon.c index e3cc97cdc6b..b5addf33751 100644 --- a/source/rpc_client/cli_netlogon.c +++ b/source/rpc_client/cli_netlogon.c @@ -604,15 +604,12 @@ NTSTATUS rpccli_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c creds_client_step(cli->dc, &clnt_creds); - prs_set_session_key(&qbuf, (const char *)cli->dc->sess_key); - prs_set_session_key(&rbuf, (const char *)cli->dc->sess_key); - init_net_q_sam_sync(&q, cli->dc->remote_machine, global_myname(), &clnt_creds, &ret_creds, database_id, next_rid); /* Marshall data and send request */ - CLI_DO_RPC(cli, mem_ctx, PI_NETLOGON, NET_SAM_SYNC, + CLI_DO_RPC_COPY_SESS_KEY(cli, mem_ctx, PI_NETLOGON, NET_SAM_SYNC, q, r, qbuf, rbuf, net_io_q_sam_sync, diff --git a/source/rpc_parse/parse_net.c b/source/rpc_parse/parse_net.c index ce2a085f478..3bd6977dbb1 100644 --- a/source/rpc_parse/parse_net.c +++ b/source/rpc_parse/parse_net.c @@ -3317,7 +3317,7 @@ BOOL net_io_r_dsr_getdcname(const char *desc, NET_R_DSR_GETDCNAME *r_t, if (!prs_uint32("ptr_dc_address", ps, depth, &r_t->ptr_dc_address)) return False; - if (!prs_uint32("dc_address_type", ps, depth, &r_t->dc_address_type)) + if (!prs_int32("dc_address_type", ps, depth, &r_t->dc_address_type)) return False; if (!smb_io_uuid("domain_guid", &r_t->domain_guid, ps, depth)) diff --git a/source/rpc_parse/parse_prs.c b/source/rpc_parse/parse_prs.c index 77f0e6d5c88..7c84ee800b9 100644 --- a/source/rpc_parse/parse_prs.c +++ b/source/rpc_parse/parse_prs.c @@ -708,6 +708,35 @@ BOOL prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32) } /******************************************************************* + Stream an int32. + ********************************************************************/ + +BOOL prs_int32(const char *name, prs_struct *ps, int depth, int32 *data32) +{ + char *q = prs_mem_get(ps, sizeof(int32)); + if (q == NULL) + return False; + + if (UNMARSHALLING(ps)) { + if (ps->bigendian_data) + *data32 = RIVALS(q,0); + else + *data32 = IVALS(q,0); + } else { + if (ps->bigendian_data) + RSIVALS(q,0,*data32); + else + SIVALS(q,0,*data32); + } + + DEBUG(5,("%s%04x %s: %08x\n", tab_depth(depth), ps->data_offset, name, *data32)); + + ps->data_offset += sizeof(int32); + + return True; +} + +/******************************************************************* Stream a NTSTATUS ********************************************************************/ diff --git a/source/rpc_parse/parse_samr.c b/source/rpc_parse/parse_samr.c index 0a055ff826a..6c2b4f4ea71 100644 --- a/source/rpc_parse/parse_samr.c +++ b/source/rpc_parse/parse_samr.c @@ -5183,6 +5183,39 @@ static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr, } /******************************************************************* +inits a SAM_USER_INFO_9 structure. +********************************************************************/ + +void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group) +{ + DEBUG(5, ("init_sam_user_info9\n")); + + usr->rid_group = rid_group; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ + +static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr, + prs_struct *ps, int depth) +{ + if (usr == NULL) + return False; + + prs_debug(ps, depth, desc, "samr_io_r_user_info9"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("rid_group", ps, depth, &usr->rid_group)) + return False; + + return True; +} + +/******************************************************************* inits a SAM_USER_INFO_16 structure. ********************************************************************/ @@ -6354,6 +6387,15 @@ static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr, } ret = sam_io_user_info7("", ctr->info.id7, ps, depth); break; + case 9: + if (UNMARSHALLING(ps)) + ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1); + if (ctr->info.id9 == NULL) { + DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); + return False; + } + ret = sam_io_user_info9("", ctr->info.id9, ps, depth); + break; case 16: if (UNMARSHALLING(ps)) ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1); diff --git a/source/rpc_parse/parse_svcctl.c b/source/rpc_parse/parse_svcctl.c index dd0c68bd797..2cb44c63195 100644 --- a/source/rpc_parse/parse_svcctl.c +++ b/source/rpc_parse/parse_svcctl.c @@ -1029,6 +1029,109 @@ BOOL svcctl_io_r_unlock_service_db(const char *desc, SVCCTL_R_UNLOCK_SERVICE_DB return True; } +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_query_service_sec(const char *desc, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_query_service_sec"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth)) + return False; + if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags)) + return False; + if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) + return False; + + return True; + +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_query_service_sec(const char *desc, SVCCTL_R_QUERY_SERVICE_SEC *r_u, prs_struct *ps, int depth) +{ + if ( !r_u ) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_query_service_sec"); + depth++; + + if(!prs_align(ps)) + return False; + + if (!prs_rpcbuffer("buffer", ps, depth, &r_u->buffer)) + return False; + + if(!prs_uint32("needed", ps, depth, &r_u->needed)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_q_set_service_sec(const char *desc, SVCCTL_Q_SET_SERVICE_SEC *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_q_set_service_sec"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!smb_io_pol_hnd("handle", &q_u->handle, ps, depth)) + return False; + if(!prs_uint32("security_flags", ps, depth, &q_u->security_flags)) + return False; + + if (!prs_rpcbuffer("buffer", ps, depth, &q_u->buffer)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) + return False; + + return True; + +} + +/******************************************************************* +********************************************************************/ + +BOOL svcctl_io_r_set_service_sec(const char *desc, SVCCTL_R_SET_SERVICE_SEC *r_u, prs_struct *ps, int depth) +{ + if ( !r_u ) + return False; + + prs_debug(ps, depth, desc, "svcctl_io_r_set_service_sec"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_werror("status", ps, depth, &r_u->status)) + return False; + + return True; +} + diff --git a/source/rpc_server/srv_eventlog_nt.c b/source/rpc_server/srv_eventlog_nt.c index 658928b9270..a8b9c66717e 100644 --- a/source/rpc_server/srv_eventlog_nt.c +++ b/source/rpc_server/srv_eventlog_nt.c @@ -56,7 +56,7 @@ static EVENTLOG_INFO *find_eventlog_info_by_hnd( pipes_struct * p, { EVENTLOG_INFO *info; - if ( !find_policy_by_hnd( p, handle, ( void ** ) &info ) ) { + if ( !find_policy_by_hnd( p, handle, (void **)(void *)&info ) ) { DEBUG( 2, ( "find_eventlog_info_by_hnd: eventlog not found.\n" ) ); return NULL; diff --git a/source/rpc_server/srv_reg_nt.c b/source/rpc_server/srv_reg_nt.c index 35a060c38e3..33711d0fac9 100644 --- a/source/rpc_server/srv_reg_nt.c +++ b/source/rpc_server/srv_reg_nt.c @@ -54,7 +54,7 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) { REGISTRY_KEY *regkey = NULL; - if(!find_policy_by_hnd(p,hnd,(void **)®key)) { + if(!find_policy_by_hnd(p,hnd,(void **)(void *)®key)) { DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); return NULL; } diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index f0ba863b4d7..334158bbbd2 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -267,7 +267,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd { Printer_entry *find_printer = NULL; - if(!find_policy_by_hnd(p,hnd,(void **)&find_printer)) { + if(!find_policy_by_hnd(p,hnd,(void **)(void *)&find_printer)) { DEBUG(2,("find_printer_index_by_hnd: Printer handle not found: ")); return NULL; } diff --git a/source/rpc_server/srv_srvsvc_nt.c b/source/rpc_server/srv_srvsvc_nt.c index 090aa4c9ff2..65e0504e678 100644 --- a/source/rpc_server/srv_srvsvc_nt.c +++ b/source/rpc_server/srv_srvsvc_nt.c @@ -1,9 +1,9 @@ - /* - * Unix SMB/CIFS implementation. +/* + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Nigel Williams 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Nigel Williams 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,6 +109,8 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstring remark; pstring path; pstring passwd; + int max_connections = lp_max_connections(snum); + uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); @@ -125,7 +127,7 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstrcpy(passwd, ""); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd); + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, max_uses, 1, path, passwd); init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } @@ -1539,6 +1541,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; + int max_connections = 0; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1583,6 +1586,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); type = q_u->info.share.info2.info_2.type; + max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; psd = NULL; break; #if 0 @@ -1651,15 +1655,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* Only call modify function if something changed. */ - if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) + if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) + || (lp_max_connections(snum) != max_connections) ) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { DEBUG(10,("_srv_net_share_set_info: No change share command\n")); return WERR_ACCESS_DENIED; } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); @@ -1706,7 +1711,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S } /******************************************************************* - Net share add. Call 'add_share_command "sharename" "pathname" "comment" "read only = xxx"' + Net share add. Call 'add_share_command "sharename" "pathname" + "comment" "max connections = " ********************************************************************/ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) @@ -1723,6 +1729,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; + int max_connections = 0; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1751,6 +1758,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name)); unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); + max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; type = q_u->info.share.info2.info_2.type; break; case 501: @@ -1787,9 +1795,8 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_INVALID_NAME; } - if ( strequal(share_name,"IPC$") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) - || strequal(share_name,"global") ) + if ( strequal(share_name,"IPC$") || strequal(share_name,"global") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) { return WERR_ACCESS_DENIED; } @@ -1813,8 +1820,13 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S string_replace(path, '"', ' '); string_replace(comment, '"', ' '); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_add_share_cmd(), + dyn_CONFIGFILE, + share_name, + path, + comment, + max_connections); DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); @@ -1951,16 +1963,17 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); + /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ + uint32 zone = get_time_zone(unixdate)/60; - tod = TALLOC_P(p->mem_ctx, TIME_OF_DAY_INFO); - if (!tod) + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + + if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) return WERR_NOMEM; - ZERO_STRUCTP(tod); - r_u->tod = tod; r_u->ptr_srv_tod = 0x1; r_u->status = WERR_OK; @@ -2312,11 +2325,7 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV switch ( q_u->type ) { case 0x9: - /* Run the name through alpha_strcpy() to remove any unsafe - shell characters. Compare the copied string with the original - and fail if the strings don't match */ - - unistr2_to_ascii(sharename, &q_u->uni_name, sizeof(sharename)); + rpcstr_pull(sharename, q_u->uni_name.buffer, sizeof(sharename), q_u->uni_name.uni_str_len*2, 0); if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); return WERR_INVALID_NAME; diff --git a/source/rpc_server/srv_svcctl.c b/source/rpc_server/srv_svcctl.c index 31d8bbe9b3d..74ae3aaa16f 100644 --- a/source/rpc_server/srv_svcctl.c +++ b/source/rpc_server/srv_svcctl.c @@ -358,6 +358,54 @@ static BOOL api_svcctl_unlock_service_db(pipes_struct *p) return True; } +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_query_security_sec(pipes_struct *p) +{ + SVCCTL_Q_QUERY_SERVICE_SEC q_u; + SVCCTL_R_QUERY_SERVICE_SEC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_query_service_sec("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_query_service_sec(p, &q_u, &r_u); + + if(!svcctl_io_r_query_service_sec("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_set_security_sec(pipes_struct *p) +{ + SVCCTL_Q_SET_SERVICE_SEC q_u; + SVCCTL_R_SET_SERVICE_SEC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_set_service_sec("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_set_service_sec(p, &q_u, &r_u); + + if(!svcctl_io_r_set_service_sec("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* \PIPE\svcctl commands @@ -378,7 +426,9 @@ static struct api_struct api_svcctl_cmds[] = { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service }, { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W , api_svcctl_query_service_status_ex }, { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB , api_svcctl_lock_service_db }, - { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db } + { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db }, + { "SVCCTL_QUERY_SERVICE_SEC" , SVCCTL_QUERY_SERVICE_SEC , api_svcctl_query_security_sec }, + { "SVCCTL_SET_SERVICE_SEC" , SVCCTL_SET_SERVICE_SEC , api_svcctl_set_security_sec } }; diff --git a/source/rpc_server/srv_svcctl_nt.c b/source/rpc_server/srv_svcctl_nt.c index 9212fe6136a..049bdf60756 100644 --- a/source/rpc_server/srv_svcctl_nt.c +++ b/source/rpc_server/srv_svcctl_nt.c @@ -186,7 +186,7 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) { SERVICE_INFO *service_info = NULL; - if( !find_policy_by_hnd( p, hnd, (void **)&service_info) ) { + if( !find_policy_by_hnd( p, hnd, (void **)(void *)&service_info) ) { DEBUG(2,("find_service_info_by_hnd: handle not found")); return NULL; } @@ -771,3 +771,100 @@ WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; } + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, SVCCTL_R_QUERY_SERVICE_SEC *r_u ) +{ + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SEC_DESC *sec_desc; + + + /* only support the SCM and individual services */ + + if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) + return WERR_BADFID; + + /* check access reights (according to MSDN) */ + + if ( !(info->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) + return WERR_ACCESS_DENIED; + + /* TODO: handle something besides DACL_SECURITY_INFORMATION */ + + if ( (q_u->security_flags & DACL_SECURITY_INFORMATION) != DACL_SECURITY_INFORMATION ) + return WERR_INVALID_PARAM; + + /* lookup the security descriptor and marshall it up for a reply */ + + if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, info->name, get_root_nt_token() )) ) + return WERR_NOMEM; + + r_u->needed = sec_desc_size( sec_desc ); + + if ( r_u->needed > q_u->buffer_size ) { + ZERO_STRUCTP( &r_u->buffer ); + return WERR_INSUFFICIENT_BUFFER; + } + + rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + + if ( !sec_io_desc("", &sec_desc, &r_u->buffer.prs, 0 ) ) + return WERR_NOMEM; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, SVCCTL_R_SET_SERVICE_SEC *r_u ) +{ + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SEC_DESC *sec_desc = NULL; + uint32 required_access; + + if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) + return WERR_BADFID; + + /* can't set the security de4scriptor on the ServiceControlManager */ + + if ( info->type == SVC_HANDLE_IS_SCM ) + return WERR_ACCESS_DENIED; + + /* check the access on the open handle */ + + switch ( q_u->security_flags ) { + case DACL_SECURITY_INFORMATION: + required_access = STD_RIGHT_WRITE_DAC_ACCESS; + break; + + case OWNER_SECURITY_INFORMATION: + case GROUP_SECURITY_INFORMATION: + required_access = STD_RIGHT_WRITE_OWNER_ACCESS; + break; + + case SACL_SECURITY_INFORMATION: + return WERR_INVALID_PARAM; + default: + return WERR_INVALID_PARAM; + } + + if ( !(info->access_granted & required_access) ) + return WERR_ACCESS_DENIED; + + /* read the security descfriptor */ + + if ( !sec_io_desc("", &sec_desc, &q_u->buffer.prs, 0 ) ) + return WERR_NOMEM; + + /* store the new SD */ + + if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, p->pipe_user.nt_user_token ) ) + return WERR_ACCESS_DENIED; + + return WERR_OK; +} + + diff --git a/source/rpcclient/cmd_lsarpc.c b/source/rpcclient/cmd_lsarpc.c index c79508de8d0..5adaf469818 100644 --- a/source/rpcclient/cmd_lsarpc.c +++ b/source/rpcclient/cmd_lsarpc.c @@ -130,8 +130,8 @@ static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli, printf("forest name is %s\n", forest_name); if (info_class == 12) { - printf("domain GUID is "); - smb_uuid_string_static(*dom_guid); + printf("domain GUID is %s\n", + smb_uuid_string_static(*dom_guid)); } rpccli_lsa_close(cli, mem_ctx, &pol); diff --git a/source/rpcclient/cmd_samr.c b/source/rpcclient/cmd_samr.c index 2050f2a7796..991b55a13c8 100644 --- a/source/rpcclient/cmd_samr.c +++ b/source/rpcclient/cmd_samr.c @@ -39,6 +39,14 @@ static void display_sam_user_info_7(SAM_USER_INFO_7 *usr) } /**************************************************************************** + display sam_user_info_9 structure + ****************************************************************************/ +static void display_sam_user_info_9(SAM_USER_INFO_9 *usr) +{ + printf("\tPrimary group RID :\tox%x\n", usr->rid_group); +} + +/**************************************************************************** display sam_user_info_21 structure ****************************************************************************/ static void display_sam_user_info_21(SAM_USER_INFO_21 *usr) @@ -141,27 +149,6 @@ static const char *display_time(NTTIME nttime) return (string); } -static const char* server_role_str(uint32 server_role) -{ - switch(server_role) { - case ROLE_STANDALONE: - return SMB_STRDUP("ROLE_STANDALONE"); - break; - case ROLE_DOMAIN_MEMBER: - return SMB_STRDUP("ROLE_DOMAIN_MEMBER"); - break; - case ROLE_DOMAIN_BDC: - return SMB_STRDUP("ROLE_DOMAIN_BDC"); - break; - case ROLE_DOMAIN_PDC: - return SMB_STRDUP("ROLE_DOMAIN_PDC"); - break; - default: - return SMB_STRDUP("Unknown -- internal error?"); - break; - } -} - static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1) { @@ -419,6 +406,9 @@ static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli, case 7: display_sam_user_info_7(user_ctr->info.id7); break; + case 9: + display_sam_user_info_9(user_ctr->info.id9); + break; default: printf("Unsupported infolevel: %d\n", info_level); break; diff --git a/source/rpcclient/cmd_srvsvc.c b/source/rpcclient/cmd_srvsvc.c index da81a82c8d5..53ee7300da3 100644 --- a/source/rpcclient/cmd_srvsvc.c +++ b/source/rpcclient/cmd_srvsvc.c @@ -433,7 +433,7 @@ static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli, SRV_FILE_INFO_CTR ctr; WERROR result; ENUM_HND hnd; - uint32 preferred_len = 0; + uint32 preferred_len = 0xffff; if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c index 46f2df29d33..5bca67d7a63 100644 --- a/source/rpcclient/rpcclient.c +++ b/source/rpcclient/rpcclient.c @@ -704,6 +704,8 @@ out_free: POPT_TABLEEND }; + load_case_tables(); + ZERO_STRUCT(server_ip); setlinebuf(stdout); diff --git a/source/sam/idmap.c b/source/sam/idmap.c index ec3ccb29859..9fc1a573a92 100644 --- a/source/sam/idmap.c +++ b/source/sam/idmap.c @@ -120,6 +120,7 @@ BOOL idmap_init(const char **remote_backend) char *rem_backend = smb_xstrdup(*remote_backend); fstring params = ""; char *pparams; + BOOL idmap_prefix_workaround = False; /* get any mode parameters passed in */ @@ -128,6 +129,13 @@ BOOL idmap_init(const char **remote_backend) pparams++; fstrcpy( params, pparams ); } + + /* strip any leading idmap_ prefix of */ + if ( strncmp( rem_backend, "idmap_", 6) == 0 ) { + rem_backend += 6; + idmap_prefix_workaround = True; + DEBUG(0, ("idmap_init: idmap backend uses deprecated 'idmap_' prefix. Please replace 'idmap_%s' by '%s' in %s\n", rem_backend, rem_backend, dyn_CONFIGFILE)); + } DEBUG(3, ("idmap_init: using '%s' as remote backend\n", rem_backend)); @@ -140,9 +148,13 @@ BOOL idmap_init(const char **remote_backend) } } else { DEBUG(0, ("idmap_init: could not load remote backend '%s'\n", rem_backend)); + if (idmap_prefix_workaround) + rem_backend -= 6; SAFE_FREE(rem_backend); return False; } + if (idmap_prefix_workaround) + rem_backend -= 6; SAFE_FREE(rem_backend); } diff --git a/source/sam/idmap_rid.c b/source/sam/idmap_rid.c index 4a1ae141b10..eced549a557 100644 --- a/source/sam/idmap_rid.c +++ b/source/sam/idmap_rid.c @@ -555,7 +555,6 @@ static struct idmap_methods rid_methods = { NTSTATUS init_module(void) { - return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "idmap_rid", &rid_methods); return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "rid", &rid_methods); } diff --git a/source/script/mkversion.sh b/source/script/mkversion.sh index 9d919cfe34b..1ba7cd63699 100755 --- a/source/script/mkversion.sh +++ b/source/script/mkversion.sh @@ -1,5 +1,4 @@ #!/bin/sh -# VERSION_FILE=$1 OUTPUT_FILE=$2 @@ -17,16 +16,12 @@ SOURCE_DIR=$3 SAMBA_VERSION_MAJOR=`sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR$VERSION_FILE` SAMBA_VERSION_MINOR=`sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR$VERSION_FILE` SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` - SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE` - SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` - SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` - SAMBA_VERSION_IS_SVN_SNAPSHOT=`sed -n 's/^SAMBA_VERSION_IS_SVN_SNAPSHOT=//p' $SOURCE_DIR$VERSION_FILE` - SAMBA_VERSION_VENDOR_SUFFIX=`sed -n 's/^SAMBA_VERSION_VENDOR_SUFFIX=//p' $SOURCE_DIR$VERSION_FILE` +SAMBA_VENDOR_PATCH=`sed -n 's/^SAMBA_VENDOR_PATCH=//p' $SOURCE_DIR$VERSION_FILE` echo "/* Autogenerated by script/mkversion.sh */" > $OUTPUT_FILE @@ -35,13 +30,21 @@ echo "#define SAMBA_VERSION_MINOR ${SAMBA_VERSION_MINOR}" >> $OUTPUT_FILE echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE +## +## start with "3.0.22" +## SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}" +## +## maybe add "3.0.22a" or "3.0.22pre1" or "3.0.22rc1" +## We do not do pre or rc version on patch/letter releases +## if test -n "${SAMBA_VERSION_REVISION}";then SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}" echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then + ## maybe add "3.0.22pre2" SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}" echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE elif test -n "${SAMBA_VERSION_RC_RELEASE}";then @@ -49,7 +52,21 @@ elif test -n "${SAMBA_VERSION_RC_RELEASE}";then echo "#define SAMBA_VERSION_RC_RELEASE ${SAMBA_VERSION_RC_RELEASE}" >> $OUTPUT_FILE fi +## +## Add the vendor string if present +## +if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then + echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE + if test -n "${SAMBA_VENDOR_PATCH}";then + echo "#define SAMBA_VENDOR_PATCH ${SAMBA_VENDOR_PATCH}" >> $OUTPUT_FILE + fi +fi + + +## +## SVN revision number? +## if test x"${SAMBA_VERSION_IS_SVN_SNAPSHOT}" = x"yes";then _SAVE_LANG=${LANG} LANG="" @@ -78,10 +95,6 @@ if test x"${SAMBA_VERSION_IS_SVN_SNAPSHOT}" = x"yes";then LANG=${_SAVE_LANG} fi -if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then - echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE -fi - echo "#define SAMBA_VERSION_OFFICIAL_STRING \"${SAMBA_VERSION_STRING}\"" >> $OUTPUT_FILE echo "#define SAMBA_VERSION_STRING samba_version_string()" >> $OUTPUT_FILE diff --git a/source/script/tests/functions b/source/script/tests/functions index 40e185e153f..8cb8f0b1550 100644 --- a/source/script/tests/functions +++ b/source/script/tests/functions @@ -34,7 +34,7 @@ stop_smbd() ## check to see if smbd is already running check_smbd_running - if test $? == 0; then + if test $? = 0; then echo "Unable to stop smbd!" exit 2 fi @@ -74,7 +74,7 @@ stop_nmbd() ## check to see if smbd is already running kill -0 $nmbd_pid 2> /dev/null - if test $? == 0; then + if test $? = 0; then echo "Unable to stop nmbd!" exit 2 fi diff --git a/source/script/tests/runtests.sh b/source/script/tests/runtests.sh index a5dc3ecfb4a..ddaf94e8ac5 100644 --- a/source/script/tests/runtests.sh +++ b/source/script/tests/runtests.sh @@ -1,11 +1,11 @@ #!/bin/sh -if [ "x$1" == "x" ]; then +if [ "x$1" = "x" ]; then echo "$0 <directory>" exit 1 fi -if [ $# == 2 ]; then +if [ $# = 2 ]; then testnum=$2 fi @@ -49,7 +49,7 @@ export USERNAME PASSWORD ## verify that we were built with --enable-socket-wrapper ## -if test "x`smbd -b | grep SOCKET_WRAPPER`" == "x"; then +if test "x`smbd -b | grep SOCKET_WRAPPER`" = "x"; then echo "***" echo "*** You must include --enable-socket-wrapper when compiling Samba" echo "*** in order to execute 'make test'. Exiting...." diff --git a/source/services/services_db.c b/source/services/services_db.c index b3ba7fcc966..a16657c0edc 100644 --- a/source/services/services_db.c +++ b/source/services/services_db.c @@ -520,6 +520,53 @@ SEC_DESC* svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN * } /******************************************************************** + Wrapper to make storing a Service sd easier +********************************************************************/ + +BOOL svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, NT_USER_TOKEN *token ) +{ + REGISTRY_KEY *key; + WERROR wresult; + pstring path; + REGVAL_CTR *values; + prs_struct ps; + BOOL ret = False; + + /* now add the security descriptor */ + + pstr_sprintf( path, "%s\\%s\\%s", KEY_SERVICES, name, "Security" ); + wresult = regkey_open_internal( &key, path, token, REG_KEY_ALL ); + if ( !W_ERROR_IS_OK(wresult) ) { + DEBUG(0,("svcctl_get_secdesc: key lookup failed! [%s] (%s)\n", + path, dos_errstr(wresult))); + return False; + } + + if ( !(values = TALLOC_ZERO_P( key, REGVAL_CTR )) ) { + DEBUG(0,("add_new_svc_name: talloc() failed!\n")); + regkey_close_internal( key ); + return False; + } + + /* stream the printer security descriptor */ + + prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, key, MARSHALL); + + if ( sec_io_desc("sec_desc", &sec_desc, &ps, 0 ) ) { + uint32 offset = prs_offset( &ps ); + regval_ctr_addvalue( values, "Security", REG_BINARY, prs_data_p(&ps), offset ); + ret = store_reg_values( key, values ); + } + + /* cleanup */ + + prs_mem_free( &ps ); + regkey_close_internal( key); + + return ret; +} + +/******************************************************************** ********************************************************************/ char* svcctl_lookup_dispname( const char *name, NT_USER_TOKEN *token ) diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c index 91dcc933227..72288e2c244 100644 --- a/source/smbd/nttrans.c +++ b/source/smbd/nttrans.c @@ -1288,7 +1288,6 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o if (!NT_STATUS_IS_OK(status) && (NT_STATUS_EQUAL(status,NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status,NT_STATUS_CANNOT_DELETE))) { restore_case_semantics(conn, file_attributes); - END_PROFILE(SMBntcreateX); return ERROR_NT(status); } } diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c index 4a08b57866f..52a61c0061b 100644 --- a/source/smbd/oplock.c +++ b/source/smbd/oplock.c @@ -48,8 +48,9 @@ int32 get_number_of_exclusive_open_oplocks(void) BOOL oplock_message_waiting(fd_set *fds) { - if (koplocks && koplocks->msg_waiting(fds)) + if (koplocks && koplocks->msg_waiting(fds)) { return True; + } return False; } @@ -84,7 +85,7 @@ void process_kernel_oplocks(void) while (koplocks->msg_waiting(&fds)) { files_struct *fsp; - struct kernel_oplock_message msg; + char msg[MSG_SMB_KERNEL_BREAK_SIZE]; fsp = koplocks->receive_message(&fds); @@ -94,12 +95,17 @@ void process_kernel_oplocks(void) return; } - msg.dev = fsp->dev; - msg.inode = fsp->inode; - msg.file_id = fsp->file_id; + /* Put the kernel break info into the message. */ + SDEV_T_VAL(msg,0,fsp->dev); + SINO_T_VAL(msg,8,fsp->inode); + SIVAL(msg,16,fsp->file_id); + + /* Don't need to be root here as we're only ever + sending to ourselves. */ + message_send_pid(pid_to_procid(sys_getpid()), MSG_SMB_KERNEL_BREAK, - &msg, sizeof(msg), True); + &msg, MSG_SMB_KERNEL_BREAK_SIZE, True); } } @@ -110,15 +116,17 @@ void process_kernel_oplocks(void) BOOL set_file_oplock(files_struct *fsp, int oplock_type) { - if (koplocks && !koplocks->set_oplock(fsp, oplock_type)) + if (koplocks && !koplocks->set_oplock(fsp, oplock_type)) { return False; + } fsp->oplock_type = oplock_type; fsp->sent_oplock_break = NO_BREAK_SENT; - if (oplock_type == LEVEL_II_OPLOCK) + if (oplock_type == LEVEL_II_OPLOCK) { level_II_oplocks_open++; - else + } else { exclusive_oplocks_open++; + } DEBUG(5,("set_file_oplock: granted oplock on file %s, dev = %x, inode = %.0f, file_id = %lu, \ tv_sec = %x, tv_usec = %x\n", @@ -140,10 +148,11 @@ void release_file_oplock(files_struct *fsp) koplocks->release_oplock(fsp); } - if (fsp->oplock_type == LEVEL_II_OPLOCK) + if (fsp->oplock_type == LEVEL_II_OPLOCK) { level_II_oplocks_open--; - else if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) + } else if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) { exclusive_oplocks_open--; + } SMB_ASSERT(exclusive_oplocks_open>=0); SMB_ASSERT(level_II_oplocks_open>=0); @@ -160,8 +169,9 @@ void release_file_oplock(files_struct *fsp) static void downgrade_file_oplock(files_struct *fsp) { - if (koplocks) + if (koplocks) { koplocks->release_oplock(fsp); + } fsp->oplock_type = LEVEL_II_OPLOCK; exclusive_oplocks_open--; level_II_oplocks_open++; @@ -252,7 +262,7 @@ int setup_oplock_select_set( fd_set *fds) ****************************************************************************/ static char *new_break_smb_message(TALLOC_CTX *mem_ctx, - files_struct *fsp, uint8_t cmd) + files_struct *fsp, uint8 cmd) { char *result = TALLOC_ARRAY(mem_ctx, char, smb_size + 8*2 + 0); @@ -284,8 +294,9 @@ static void wait_before_sending_break(void) struct timeval cur_tv; long wait_left = (long)lp_oplock_break_wait_time(); - if (wait_left == 0) + if (wait_left == 0) { return; + } GetTimeOfDay(&cur_tv); @@ -307,7 +318,7 @@ static files_struct *initial_break_processing(SMB_DEV_T dev, SMB_INO_T inode, un files_struct *fsp = NULL; if( DEBUGLVL( 3 ) ) { - dbgtext( "initial_break_processing: called for dev = %x, inode = %.0f file_id = %lu\n", + dbgtext( "initial_break_processing: called for dev = 0x%x, inode = %.0f file_id = %lu\n", (unsigned int)dev, (double)inode, file_id); dbgtext( "Current oplocks_open (exclusive = %d, levelII = %d)\n", exclusive_oplocks_open, level_II_oplocks_open ); @@ -325,7 +336,7 @@ static files_struct *initial_break_processing(SMB_DEV_T dev, SMB_INO_T inode, un /* The file could have been closed in the meantime - return success. */ if( DEBUGLVL( 3 ) ) { dbgtext( "initial_break_processing: cannot find open file with " ); - dbgtext( "dev = %x, inode = %.0f file_id = %lu", (unsigned int)dev, + dbgtext( "dev = 0x%x, inode = %.0f file_id = %lu", (unsigned int)dev, (double)inode, file_id); dbgtext( "allowing break to succeed.\n" ); } @@ -370,7 +381,7 @@ static void oplock_timeout_handler(struct timed_event *te, static void process_oplock_break_message(int msg_type, struct process_id src, void *buf, size_t len) { - struct share_mode_entry *msg = buf; + struct share_mode_entry msg; files_struct *fsp; char *break_msg; BOOL break_to_level2 = False; @@ -381,17 +392,20 @@ static void process_oplock_break_message(int msg_type, struct process_id src, return; } - if (len != sizeof(*msg)) { + if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) { DEBUG(0, ("Got invalid msg len %d\n", (int)len)); return; } - DEBUG(10, ("Got oplock break message from pid %d: %d/%d/%d\n", - (int)procid_to_pid(&src), (int)msg->dev, (int)msg->inode, - (int)msg->share_file_id)); + /* De-linearize incoming message. */ + message_to_share_mode_entry(&msg, buf); - fsp = initial_break_processing(msg->dev, msg->inode, - msg->share_file_id); + DEBUG(10, ("Got oplock break message from pid %d: 0x%x/%.0f/%d\n", + (int)procid_to_pid(&src), (unsigned int)msg.dev, (double)msg.inode, + (int)msg.share_file_id)); + + fsp = initial_break_processing(msg.dev, msg.inode, + msg.share_file_id); if (fsp == NULL) { /* We hit race here. Break messages are sent, and before we @@ -399,8 +413,11 @@ static void process_oplock_break_message(int msg_type, struct process_id src, * with 'ok, oplock broken' */ DEBUG(3, ("Did not find fsp\n")); become_root(); + + /* We just send the same message back. */ message_send_pid(src, MSG_SMB_BREAK_RESPONSE, - msg, sizeof(*msg), True); + buf, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); + unbecome_root(); return; } @@ -408,21 +425,24 @@ static void process_oplock_break_message(int msg_type, struct process_id src, if (fsp->sent_oplock_break != NO_BREAK_SENT) { /* Remember we have to inform the requesting PID when the * client replies */ - msg->pid = src; - ADD_TO_ARRAY(NULL, struct share_mode_entry, *msg, + msg.pid = src; + ADD_TO_ARRAY(NULL, struct share_mode_entry, msg, &fsp->pending_break_messages, &fsp->num_pending_break_messages); return; } - if (EXCLUSIVE_OPLOCK_TYPE(msg->op_type) && + if (EXCLUSIVE_OPLOCK_TYPE(msg.op_type) && !EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) { - DEBUG(3, ("Already downgraded oplock on %.0f/%.0f: %s\n", - (double)fsp->dev, (double)fsp->inode, + DEBUG(3, ("Already downgraded oplock on 0x%x/%.0f: %s\n", + (unsigned int)fsp->dev, (double)fsp->inode, fsp->fsp_name)); become_root(); + + /* We just send the same message back. */ message_send_pid(src, MSG_SMB_BREAK_RESPONSE, - msg, sizeof(*msg), True); + buf, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); + unbecome_root(); return; } @@ -466,8 +486,8 @@ static void process_oplock_break_message(int msg_type, struct process_id src, /* Async level2 request, don't send a reply */ fsp->sent_oplock_break = ASYNC_LEVEL_II_BREAK_SENT; } - msg->pid = src; - ADD_TO_ARRAY(NULL, struct share_mode_entry, *msg, + msg.pid = src; + ADD_TO_ARRAY(NULL, struct share_mode_entry, msg, &fsp->pending_break_messages, &fsp->num_pending_break_messages); @@ -490,7 +510,9 @@ static void process_oplock_break_message(int msg_type, struct process_id src, static void process_kernel_oplock_break(int msg_type, struct process_id src, void *buf, size_t len) { - struct kernel_oplock_message *msg = buf; + SMB_DEV_T dev; + SMB_INO_T inode; + unsigned long file_id; files_struct *fsp; char *break_msg; BOOL sign_state; @@ -500,16 +522,21 @@ static void process_kernel_oplock_break(int msg_type, struct process_id src, return; } - if (len != sizeof(*msg)) { + if (len != MSG_SMB_KERNEL_BREAK_SIZE) { DEBUG(0, ("Got invalid msg len %d\n", (int)len)); return; } - DEBUG(10, ("Got kernel oplock break message from pid %d: %d/%d/%d\n", - (int)procid_to_pid(&src), (int)msg->dev, (int)msg->inode, - (int)msg->file_id)); + /* Pull the data from the message. */ + dev = DEV_T_VAL(buf, 0); + inode = INO_T_VAL(buf, 8); + file_id = (unsigned long)IVAL(buf, 16); + + DEBUG(10, ("Got kernel oplock break message from pid %d: 0x%x/%.0f/%u\n", + (int)procid_to_pid(&src), (unsigned int)dev, (double)inode, + (unsigned int)file_id)); - fsp = initial_break_processing(msg->dev, msg->inode, msg->file_id); + fsp = initial_break_processing(dev, inode, file_id); if (fsp == NULL) { DEBUG(3, ("Got a kernel oplock break message for a file " @@ -551,9 +578,13 @@ void reply_to_oplock_break_requests(files_struct *fsp) become_root(); for (i=0; i<fsp->num_pending_break_messages; i++) { - struct share_mode_entry *msg = &fsp->pending_break_messages[i]; - message_send_pid(msg->pid, MSG_SMB_BREAK_RESPONSE, - msg, sizeof(*msg), True); + struct share_mode_entry *e = &fsp->pending_break_messages[i]; + char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE]; + + share_mode_entry_to_message(msg, e); + + message_send_pid(e->pid, MSG_SMB_BREAK_RESPONSE, + msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); } unbecome_root(); @@ -569,46 +600,52 @@ void reply_to_oplock_break_requests(files_struct *fsp) static void process_oplock_break_response(int msg_type, struct process_id src, void *buf, size_t len) { - struct share_mode_entry *msg = buf; + struct share_mode_entry msg; if (buf == NULL) { DEBUG(0, ("Got NULL buffer\n")); return; } - if (len != sizeof(*msg)) { - DEBUG(0, ("Got invalid msg len %d\n", (int)len)); + if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) { + DEBUG(0, ("Got invalid msg len %u\n", (unsigned int)len)); return; } - DEBUG(10, ("Got oplock break response from pid %d: %d/%d/%d mid %d\n", - (int)procid_to_pid(&src), (int)msg->dev, (int)msg->inode, - (int)msg->share_file_id, (int)msg->op_mid)); + /* De-linearize incoming message. */ + message_to_share_mode_entry(&msg, buf); + + DEBUG(10, ("Got oplock break response from pid %d: 0x%x/%.0f/%u mid %u\n", + (int)procid_to_pid(&src), (unsigned int)msg.dev, (double)msg.inode, + (unsigned int)msg.share_file_id, (unsigned int)msg.op_mid)); /* Here's the hack from open.c, store the mid in the 'port' field */ - schedule_deferred_open_smb_message(msg->op_mid); + schedule_deferred_open_smb_message(msg.op_mid); } static void process_open_retry_message(int msg_type, struct process_id src, void *buf, size_t len) { - struct share_mode_entry *msg = buf; + struct share_mode_entry msg; if (buf == NULL) { DEBUG(0, ("Got NULL buffer\n")); return; } - if (len != sizeof(*msg)) { + if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) { DEBUG(0, ("Got invalid msg len %d\n", (int)len)); return; } - DEBUG(10, ("Got open retry msg from pid %d: %d/%d mid %d\n", - (int)procid_to_pid(&src), (int)msg->dev, (int)msg->inode, - (int)msg->op_mid)); + /* De-linearize incoming message. */ + message_to_share_mode_entry(&msg, buf); - schedule_deferred_open_smb_message(msg->op_mid); + DEBUG(10, ("Got open retry msg from pid %d: 0x%x/%.0f mid %u\n", + (int)procid_to_pid(&src), (unsigned int)msg.dev, (double)msg.inode, + (unsigned int)msg.op_mid)); + + schedule_deferred_open_smb_message(msg.op_mid); } /**************************************************************************** @@ -662,6 +699,7 @@ void release_level_2_oplocks_on_change(files_struct *fsp) for(i = 0; i < lck->num_share_modes; i++) { struct share_mode_entry *share_entry = &lck->share_modes[i]; + char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE]; /* * As there could have been multiple writes waiting at the @@ -692,9 +730,11 @@ void release_level_2_oplocks_on_change(files_struct *fsp) abort(); } + share_mode_entry_to_message(msg, share_entry); + become_root(); message_send_pid(share_entry->pid, MSG_SMB_ASYNC_LEVEL2_BREAK, - share_entry, sizeof(*share_entry), True); + msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True); unbecome_root(); } @@ -703,6 +743,44 @@ void release_level_2_oplocks_on_change(files_struct *fsp) } /**************************************************************************** + Linearize a share mode entry struct to an internal oplock break message. +****************************************************************************/ + +void share_mode_entry_to_message(char *msg, struct share_mode_entry *e) +{ + SIVAL(msg,0,(uint32)e->pid.pid); + SSVAL(msg,4,e->op_mid); + SSVAL(msg,6,e->op_type); + SIVAL(msg,8,e->access_mask); + SIVAL(msg,12,e->share_access); + SIVAL(msg,16,e->private_options); + SIVAL(msg,20,(uint32)e->time.tv_sec); + SIVAL(msg,24,(uint32)e->time.tv_usec); + SDEV_T_VAL(msg,28,e->dev); + SINO_T_VAL(msg,36,e->inode); + SIVAL(msg,44,e->share_file_id); +} + +/**************************************************************************** + De-linearize an internal oplock break message to a share mode entry struct. +****************************************************************************/ + +void message_to_share_mode_entry(struct share_mode_entry *e, char *msg) +{ + e->pid.pid = (pid_t)IVAL(msg,0); + e->op_mid = SVAL(msg,4); + e->op_type = SVAL(msg,6); + e->access_mask = IVAL(msg,8); + e->share_access = IVAL(msg,12); + e->private_options = IVAL(msg,16); + e->time.tv_sec = (time_t)IVAL(msg,20); + e->time.tv_usec = (int)IVAL(msg,24); + e->dev = DEV_T_VAL(msg,28); + e->inode = INO_T_VAL(msg,36); + e->share_file_id = (unsigned long)IVAL(msg,44); +} + +/**************************************************************************** Setup oplocks for this process. ****************************************************************************/ diff --git a/source/smbd/password.c b/source/smbd/password.c index 9ee721089c9..764fbe8a2e9 100644 --- a/source/smbd/password.c +++ b/source/smbd/password.c @@ -381,9 +381,14 @@ BOOL user_ok(const char *user,int snum, gid_t *groups, size_t n_groups) if (lp_invalid_users(snum)) { str_list_copy(&invalid, lp_invalid_users(snum)); - if (invalid && str_list_substitute(invalid, "%S", lp_servicename(snum))) { - if ( invalid && str_list_sub_basic(invalid, current_user_info.smb_name) ) { - ret = !user_in_list(user, (const char **)invalid, groups, n_groups); + if (invalid && + str_list_substitute(invalid, "%S", lp_servicename(snum))) { + if ( invalid && + str_list_sub_basic(invalid, + current_user_info.smb_name) ) { + ret = !user_in_list(user, + (const char **)invalid, + groups, n_groups); } } } @@ -392,9 +397,13 @@ BOOL user_ok(const char *user,int snum, gid_t *groups, size_t n_groups) if (ret && lp_valid_users(snum)) { str_list_copy(&valid, lp_valid_users(snum)); - if ( valid && str_list_substitute(valid, "%S", lp_servicename(snum)) ) { - if ( valid && str_list_sub_basic(valid, current_user_info.smb_name) ) { - ret = user_in_list(user, (const char **)valid, groups, n_groups); + if ( valid && + str_list_substitute(valid, "%S", lp_servicename(snum)) ) { + if ( valid && + str_list_sub_basic(valid, + current_user_info.smb_name) ) { + ret = user_in_list(user, (const char **)valid, + groups, n_groups); } } } @@ -403,8 +412,11 @@ BOOL user_ok(const char *user,int snum, gid_t *groups, size_t n_groups) if (ret && lp_onlyuser(snum)) { char **user_list = str_list_make (lp_username(snum), NULL); - if (user_list && str_list_substitute(user_list, "%S", lp_servicename(snum))) { - ret = user_in_list(user, (const char **)user_list, groups, n_groups); + if (user_list && + str_list_substitute(user_list, "%S", + lp_servicename(snum))) { + ret = user_in_list(user, (const char **)user_list, + groups, n_groups); } if (user_list) str_list_free (&user_list); } @@ -509,19 +521,21 @@ BOOL authorise_login(int snum, fstring user, DATA_BLOB password, BOOL ok = False; #ifdef DEBUG_PASSWORD - DEBUG(100,("authorise_login: checking authorisation on user=%s pass=%s\n", - user,password.data)); + DEBUG(100,("authorise_login: checking authorisation on " + "user=%s pass=%s\n", user,password.data)); #endif *guest = False; /* there are several possibilities: 1) login as the given user with given password - 2) login as a previously registered username with the given password + 2) login as a previously registered username with the given + password 3) login as a session list username with the given password 4) login as a previously validated user/password pair 5) login as the "user =" user with given password - 6) login as the "user =" user with no password (guest connection) + 6) login as the "user =" user with no password + (guest connection) 7) login as guest user with no password if the service is guest_only then steps 1 to 5 are skipped @@ -550,11 +564,12 @@ BOOL authorise_login(int snum, fstring user, DATA_BLOB password, if (password_ok(user2,password)) { ok = True; fstrcpy(user,user2); - DEBUG(3,("authorise_login: ACCEPTED: session list username (%s) \ -and given password ok\n", user)); + DEBUG(3,("authorise_login: ACCEPTED: session " + "list username (%s) and given " + "password ok\n", user)); } } - + SAFE_FREE(user_list); } @@ -573,17 +588,21 @@ and given password ok\n", user)); if (auser) { ok = True; fstrcpy(user,auser); - DEBUG(3,("authorise_login: ACCEPTED: group username \ -and given password ok (%s)\n", user)); + DEBUG(3,("authorise_login: ACCEPTED: " + "group username and given " + "password ok (%s)\n", user)); } } else { fstring user2; fstrcpy(user2,auser); - if (user_ok(user2,snum, NULL, 0) && password_ok(user2,password)) { + if (user_ok(user2,snum, NULL, 0) && + password_ok(user2,password)) { ok = True; fstrcpy(user,user2); - DEBUG(3,("authorise_login: ACCEPTED: user list username \ -and given password ok (%s)\n", user)); + DEBUG(3,("authorise_login: ACCEPTED: " + "user list username and " + "given password ok (%s)\n", + user)); } } } @@ -596,10 +615,11 @@ and given password ok (%s)\n", user)); if (Get_Pwnam(guestname)) { fstrcpy(user,guestname); ok = True; - DEBUG(3,("authorise_login: ACCEPTED: guest account and guest ok (%s)\n", - user)); + DEBUG(3,("authorise_login: ACCEPTED: guest account " + "and guest ok (%s)\n", user)); } else { - DEBUG(0,("authorise_login: Invalid guest account %s??\n",guestname)); + DEBUG(0,("authorise_login: Invalid guest account " + "%s??\n",guestname)); } *guest = True; } diff --git a/source/smbd/posix_acls.c b/source/smbd/posix_acls.c index 91a3f5ed481..7187f61b023 100644 --- a/source/smbd/posix_acls.c +++ b/source/smbd/posix_acls.c @@ -4149,10 +4149,14 @@ BOOL can_delete_file_in_directory(connection_struct *conn, const char *fname) if(SMB_VFS_STAT(conn, fname, &sbuf_file) != 0) { return False; } - if (current_user.uid == sbuf_file.st_uid) { - return True; + /* + * Patch from SATOH Fumiyasu <fumiyas@miraclelinux.com> + * for bug #3348. Don't assume owning sticky bit + * directory means write access allowed. + */ + if (current_user.uid != sbuf_file.st_uid) { + return False; } - return False; } #endif diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c index ee6bed9afdf..fc2a7686bd1 100644 --- a/source/smbd/trans2.c +++ b/source/smbd/trans2.c @@ -1536,7 +1536,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SIVAL(p,4,0); p+= 8; - SINO_T(p,0,(SMB_INO_T)sbuf.st_ino); /* inode number */ + SINO_T_VAL(p,0,(SMB_INO_T)sbuf.st_ino); /* inode number */ p+= 8; SIVAL(p,0, unix_perms_to_wire(sbuf.st_mode)); /* Standard UNIX file permissions */ @@ -3361,7 +3361,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd SIVAL(pdata,4,0); pdata += 8; - SINO_T(pdata,0,(SMB_INO_T)sbuf.st_ino); /* inode number */ + SINO_T_VAL(pdata,0,(SMB_INO_T)sbuf.st_ino); /* inode number */ pdata += 8; SIVAL(pdata,0, unix_perms_to_wire(sbuf.st_mode)); /* Standard UNIX file permissions */ diff --git a/source/tdb/tdbtool.c b/source/tdb/tdbtool.c index ce8490ea065..bcfb96adc09 100644 --- a/source/tdb/tdbtool.c +++ b/source/tdb/tdbtool.c @@ -232,6 +232,11 @@ static void insert_tdb(char *keyname, size_t keylen, char* data, size_t datalen) { TDB_DATA key, dbuf; + if ((keyname == NULL) || (keylen == 0)) { + terror("need key"); + return; + } + key.dptr = keyname; key.dsize = keylen; dbuf.dptr = data; @@ -246,6 +251,16 @@ static void store_tdb(char *keyname, size_t keylen, char* data, size_t datalen) { TDB_DATA key, dbuf; + if ((keyname == NULL) || (keylen == 0)) { + terror("need key"); + return; + } + + if ((data == NULL) || (datalen == 0)) { + terror("need data"); + return; + } + key.dptr = keyname; key.dsize = keylen; dbuf.dptr = data; @@ -263,6 +278,11 @@ static void show_tdb(char *keyname, size_t keylen) { TDB_DATA key, dbuf; + if ((keyname == NULL) || (keylen == 0)) { + terror("need key"); + return; + } + key.dptr = keyname; key.dsize = keylen; @@ -283,6 +303,11 @@ static void delete_tdb(char *keyname, size_t keylen) { TDB_DATA key; + if ((keyname == NULL) || (keylen == 0)) { + terror("need key"); + return; + } + key.dptr = keyname; key.dsize = keylen; @@ -296,6 +321,11 @@ static void move_rec(char *keyname, size_t keylen, char* tdbname) TDB_DATA key, dbuf; TDB_CONTEXT *dst_tdb; + if ((keyname == NULL) || (keylen == 0)) { + terror("need key"); + return; + } + if ( !tdbname ) { terror("need destination tdb name"); return; diff --git a/source/tdb/tdbutil.c b/source/tdb/tdbutil.c index ac9280cf8bd..53011006327 100644 --- a/source/tdb/tdbutil.c +++ b/source/tdb/tdbutil.c @@ -485,7 +485,7 @@ size_t tdb_pack(char *buf, int bufsize, const char *fmt, ...) return result; } -BOOL tdb_pack_append(TALLOC_CTX *mem_ctx, uint8_t **buf, size_t *len, +BOOL tdb_pack_append(TALLOC_CTX *mem_ctx, uint8 **buf, size_t *len, const char *fmt, ...) { va_list ap; @@ -496,10 +496,10 @@ BOOL tdb_pack_append(TALLOC_CTX *mem_ctx, uint8_t **buf, size_t *len, va_end(ap); if (mem_ctx != NULL) - *buf = TALLOC_REALLOC_ARRAY(mem_ctx, *buf, uint8_t, + *buf = TALLOC_REALLOC_ARRAY(mem_ctx, *buf, uint8, (*len) + len1); else - *buf = SMB_REALLOC_ARRAY(*buf, uint8_t, (*len) + len1); + *buf = SMB_REALLOC_ARRAY(*buf, uint8, (*len) + len1); if (*buf == NULL) return False; diff --git a/source/utils/eventlogadm.c b/source/utils/eventlogadm.c index a0fc4bcf9d4..eef7cde3771 100644 --- a/source/utils/eventlogadm.c +++ b/source/utils/eventlogadm.c @@ -166,6 +166,8 @@ int main( int argc, char *argv[] ) fstring opname; + load_case_tables(); + opt_debug = 0; /* todo set this from getopts */ lp_load( dyn_CONFIGFILE, True, False, False ); diff --git a/source/utils/net.c b/source/utils/net.c index 4d9dec4b85b..a2a9ac6a391 100644 --- a/source/utils/net.c +++ b/source/utils/net.c @@ -128,7 +128,7 @@ int net_run_function(int argc, const char **argv, struct functable *table, if (StrCaseCmp(argv[0], table[i].funcname) == 0) return table[i].fn(argc-1, argv+1); } - d_printf("No command: %s\n", argv[0]); + d_fprintf(stderr, "No command: %s\n", argv[0]); return usage_fn(argc, argv); } @@ -158,21 +158,21 @@ NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip, if (NT_STATUS_IS_OK(nt_status)) { return nt_status; } else { - d_printf("Could not connect to server %s\n", server_name); + d_fprintf(stderr, "Could not connect to server %s\n", server_name); /* Display a nicer message depending on the result */ if (NT_STATUS_V(nt_status) == NT_STATUS_V(NT_STATUS_LOGON_FAILURE)) - d_printf("The username or password was not correct.\n"); + d_fprintf(stderr, "The username or password was not correct.\n"); if (NT_STATUS_V(nt_status) == NT_STATUS_V(NT_STATUS_ACCOUNT_LOCKED_OUT)) - d_printf("The account was locked out.\n"); + d_fprintf(stderr, "The account was locked out.\n"); if (NT_STATUS_V(nt_status) == NT_STATUS_V(NT_STATUS_ACCOUNT_DISABLED)) - d_printf("The account was disabled.\n"); + d_fprintf(stderr, "The account was disabled.\n"); return nt_status; } @@ -257,7 +257,7 @@ int net_use_machine_password(void) char *user_name = NULL; if (!secrets_init()) { - d_printf("ERROR: Unable to open secrets database\n"); + d_fprintf(stderr, "ERROR: Unable to open secrets database\n"); exit(1); } @@ -362,7 +362,7 @@ struct cli_state *net_make_ipc_connection(unsigned flags) NTSTATUS nt_status; if (!net_find_server(flags, &server_ip, &server_name)) { - d_printf("\nUnable to find a suitable server\n"); + d_fprintf(stderr, "\nUnable to find a suitable server\n"); return NULL; } @@ -409,7 +409,7 @@ static int net_join(int argc, const char **argv) if (net_ads_join(argc, argv) == 0) return 0; else - d_printf("ADS join did not work, falling back to RPC...\n"); + d_fprintf(stderr, "ADS join did not work, falling back to RPC...\n"); } return net_rpc_join(argc, argv); } @@ -431,7 +431,7 @@ static int net_changesecretpw(int argc, const char **argv) trust_pw = getpass("Enter machine password: "); if (!secrets_store_machine_password(trust_pw, lp_workgroup(), sec_channel_type)) { - d_printf("Unable to write the machine account password in the secrets database"); + d_fprintf(stderr, "Unable to write the machine account password in the secrets database"); return 1; } else { @@ -486,7 +486,7 @@ static int net_getlocalsid(int argc, const char **argv) panic when we can't. */ if (!secrets_init()) { - d_printf("Unable to open secrets.tdb. Can't fetch domain SID for name: %s\n", name); + d_fprintf(stderr, "Unable to open secrets.tdb. Can't fetch domain SID for name: %s\n", name); return 1; } @@ -536,14 +536,14 @@ static int net_getdomainsid(int argc, const char **argv) get_global_sam_sid(); if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) { - d_printf("Could not fetch local SID\n"); + d_fprintf(stderr, "Could not fetch local SID\n"); return 1; } sid_to_string(sid_str, &domain_sid); d_printf("SID for domain %s is: %s\n", global_myname(), sid_str); if (!secrets_fetch_domain_sid(opt_workgroup, &domain_sid)) { - d_printf("Could not fetch domain SID\n"); + d_fprintf(stderr, "Could not fetch domain SID\n"); return 1; } @@ -575,22 +575,22 @@ static int net_afs_key(int argc, const char **argv) } if (!secrets_init()) { - d_printf("Could not open secrets.tdb\n"); + d_fprintf(stderr, "Could not open secrets.tdb\n"); return -1; } if ((fd = open(argv[0], O_RDONLY, 0)) < 0) { - d_printf("Could not open %s\n", argv[0]); + d_fprintf(stderr, "Could not open %s\n", argv[0]); return -1; } if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) { - d_printf("Could not read keyfile\n"); + d_fprintf(stderr, "Could not read keyfile\n"); return -1; } if (!secrets_store_afs_keyfile(argv[1], &keyfile)) { - d_printf("Could not write keyfile to secrets.tdb\n"); + d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n"); return -1; } @@ -642,7 +642,7 @@ static BOOL search_maxrid(struct pdb_search *search, const char *type, uint32 i, num_entries; if (search == NULL) { - d_printf("get_maxrid: Could not search %s\n", type); + d_fprintf(stderr, "get_maxrid: Could not search %s\n", type); return False; } @@ -781,6 +781,8 @@ static struct functable net_func[] = { zero_ip(&opt_dest_ip); + load_case_tables(); + /* set default debug level to 0 regardless of what smb.conf sets */ DEBUGLEVEL_CLASS[DBGC_ALL] = 0; dbf = x_stderr; @@ -797,7 +799,7 @@ static struct functable net_func[] = { case 'I': opt_dest_ip = *interpret_addr2(poptGetOptArg(pc)); if (is_zero_ip(opt_dest_ip)) - d_printf("\nInvalid ip address specified\n"); + d_fprintf(stderr, "\nInvalid ip address specified\n"); else opt_have_ip = True; break; @@ -811,7 +813,7 @@ static struct functable net_func[] = { } break; default: - d_printf("\nInvalid option %s: %s\n", + d_fprintf(stderr, "\nInvalid option %s: %s\n", poptBadOption(pc, 0), poptStrerror(opt)); net_help(argc, argv); exit(1); diff --git a/source/utils/net_ads.c b/source/utils/net_ads.c index 49a7f1cc2dd..f54896b3a82 100644 --- a/source/utils/net_ads.c +++ b/source/utils/net_ads.c @@ -78,7 +78,7 @@ static int net_ads_lookup(int argc, const char **argv) ads_connect(ads); if (!ads) { - d_printf("Didn't find the cldap server!\n"); + d_fprintf(stderr, "Didn't find the cldap server!\n"); return -1; } if (!ads->config.realm) { ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup); @@ -108,7 +108,7 @@ static int net_ads_info(int argc, const char **argv) ads_connect(ads); if (!ads || !ads->config.realm) { - d_printf("Didn't find the ldap server!\n"); + d_fprintf(stderr, "Didn't find the ldap server!\n"); return -1; } @@ -229,7 +229,7 @@ static int net_ads_workgroup(int argc, const char **argv) } if (!ADS_ERR_OK(ads_workgroup_name(ads, ctx, &workgroup))) { - d_printf("Failed to find workgroup for realm '%s'\n", + d_fprintf(stderr, "Failed to find workgroup for realm '%s'\n", ads->config.realm); talloc_destroy(ctx); ads_destroy(&ads); @@ -295,12 +295,12 @@ static int ads_user_add(int argc, const char **argv) status = ads_find_user_acct(ads, &res, argv[0]); if (!ADS_ERR_OK(status)) { - d_printf("ads_user_add: %s\n", ads_errstr(status)); + d_fprintf(stderr, "ads_user_add: %s\n", ads_errstr(status)); goto done; } if (ads_count_replies(ads, res)) { - d_printf("ads_user_add: User %s already exists\n", argv[0]); + d_fprintf(stderr, "ads_user_add: User %s already exists\n", argv[0]); goto done; } @@ -311,7 +311,7 @@ static int ads_user_add(int argc, const char **argv) status = ads_add_user_acct(ads, argv[0], opt_container, opt_comment); if (!ADS_ERR_OK(status)) { - d_printf("Could not add user %s: %s\n", argv[0], + d_fprintf(stderr, "Could not add user %s: %s\n", argv[0], ads_errstr(status)); goto done; } @@ -335,7 +335,7 @@ static int ads_user_add(int argc, const char **argv) } /* password didn't set, delete account */ - d_printf("Could not add user %s. Error setting password %s\n", + d_fprintf(stderr, "Could not add user %s. Error setting password %s\n", argv[0], ads_errstr(status)); ads_msgfree(ads, res); status=ads_find_user_acct(ads, &res, argv[0]); @@ -373,7 +373,7 @@ static int ads_user_info(int argc, const char **argv) } if (!escaped_user) { - d_printf("ads_user_info: failed to escape user %s\n", argv[0]); + d_fprintf(stderr, "ads_user_info: failed to escape user %s\n", argv[0]); ads_destroy(&ads); return -1; } @@ -383,7 +383,7 @@ static int ads_user_info(int argc, const char **argv) safe_free(searchstring); if (!ADS_ERR_OK(rc)) { - d_printf("ads_search: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_search: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } @@ -436,7 +436,7 @@ static int ads_user_delete(int argc, const char **argv) ads_destroy(&ads); return 0; } - d_printf("Error deleting user %s: %s\n", argv[0], + d_fprintf(stderr, "Error deleting user %s: %s\n", argv[0], ads_errstr(rc)); ads_destroy(&ads); return -1; @@ -501,12 +501,12 @@ static int ads_group_add(int argc, const char **argv) status = ads_find_user_acct(ads, &res, argv[0]); if (!ADS_ERR_OK(status)) { - d_printf("ads_group_add: %s\n", ads_errstr(status)); + d_fprintf(stderr, "ads_group_add: %s\n", ads_errstr(status)); goto done; } if (ads_count_replies(ads, res)) { - d_printf("ads_group_add: Group %s already exists\n", argv[0]); + d_fprintf(stderr, "ads_group_add: Group %s already exists\n", argv[0]); ads_msgfree(ads, res); goto done; } @@ -521,7 +521,7 @@ static int ads_group_add(int argc, const char **argv) d_printf("Group %s added\n", argv[0]); rc = 0; } else { - d_printf("Could not add group %s: %s\n", argv[0], + d_fprintf(stderr, "Could not add group %s: %s\n", argv[0], ads_errstr(status)); } @@ -562,7 +562,7 @@ static int ads_group_delete(int argc, const char **argv) ads_destroy(&ads); return 0; } - d_printf("Error deleting group %s: %s\n", argv[0], + d_fprintf(stderr, "Error deleting group %s: %s\n", argv[0], ads_errstr(rc)); ads_destroy(&ads); return -1; @@ -614,13 +614,13 @@ static int net_ads_status(int argc, const char **argv) rc = ads_find_machine_acct(ads, &res, global_myname()); if (!ADS_ERR_OK(rc)) { - d_printf("ads_find_machine_acct: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_find_machine_acct: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } if (ads_count_replies(ads, res) == 0) { - d_printf("No machine account for '%s' found\n", global_myname()); + d_fprintf(stderr, "No machine account for '%s' found\n", global_myname()); ads_destroy(&ads); return -1; } @@ -650,7 +650,7 @@ static int net_ads_leave(int argc, const char **argv) rc = ads_leave_realm(ads, global_myname()); if (!ADS_ERR_OK(rc)) { - d_printf("Failed to delete host '%s' from the '%s' realm.\n", + d_fprintf(stderr, "Failed to delete host '%s' from the '%s' realm.\n", global_myname(), ads->config.realm); ads_destroy(&ads); return -1; @@ -734,13 +734,13 @@ int net_ads_join(int argc, const char **argv) } if (!*lp_realm()) { - d_printf("realm must be set in in smb.conf for ADS join to succeed.\n"); + d_fprintf(stderr, "realm must be set in in smb.conf for ADS join to succeed.\n"); ads_destroy(&ads); return -1; } if (strcmp(ads->config.realm, lp_realm()) != 0) { - d_printf("realm of remote server (%s) and realm in smb.conf (%s) DO NOT match. Aborting join\n", ads->config.realm, lp_realm()); + d_fprintf(stderr, "realm of remote server (%s) and realm in smb.conf (%s) DO NOT match. Aborting join\n", ads->config.realm, lp_realm()); ads_destroy(&ads); return -1; } @@ -753,7 +753,7 @@ int net_ads_join(int argc, const char **argv) ads_msgfree(ads, res); if (rc.error_type == ENUM_ADS_ERROR_LDAP && rc.err.rc == LDAP_NO_SUCH_OBJECT) { - d_printf("ads_join_realm: organizational unit %s does not exist (dn:%s)\n", + d_fprintf(stderr, "ads_join_realm: organizational unit %s does not exist (dn:%s)\n", org_unit, dn); ads_destroy(&ads); return -1; @@ -761,34 +761,34 @@ int net_ads_join(int argc, const char **argv) free(dn); if (!ADS_ERR_OK(rc)) { - d_printf("ads_join_realm: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_join_realm: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } rc = ads_join_realm(ads, global_myname(), account_type, org_unit); if (!ADS_ERR_OK(rc)) { - d_printf("ads_join_realm: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_join_realm: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } rc = ads_domain_sid(ads, &dom_sid); if (!ADS_ERR_OK(rc)) { - d_printf("ads_domain_sid: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_domain_sid: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } if (asprintf(&machine_account, "%s$", global_myname()) == -1) { - d_printf("asprintf failed\n"); + d_fprintf(stderr, "asprintf failed\n"); ads_destroy(&ads); return -1; } rc = ads_set_machine_password(ads, machine_account, password); if (!ADS_ERR_OK(rc)) { - d_printf("ads_set_machine_password: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_set_machine_password: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } @@ -796,7 +796,7 @@ int net_ads_join(int argc, const char **argv) /* make sure we get the right workgroup */ if ( !(ctx = talloc_init("net ads join")) ) { - d_printf("talloc_init() failed!\n"); + d_fprintf(stderr, "talloc_init() failed!\n"); ads_destroy(&ads); return -1; } @@ -904,14 +904,14 @@ static int net_ads_printer_search(int argc, const char **argv) rc = ads_find_printers(ads, &res); if (!ADS_ERR_OK(rc)) { - d_printf("ads_find_printer: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_find_printer: %s\n", ads_errstr(rc)); ads_msgfree(ads, res); ads_destroy(&ads); return -1; } if (ads_count_replies(ads, res) == 0) { - d_printf("No results found\n"); + d_fprintf(stderr, "No results found\n"); ads_msgfree(ads, res); ads_destroy(&ads); return -1; @@ -949,14 +949,14 @@ static int net_ads_printer_info(int argc, const char **argv) rc = ads_find_printer_on_server(ads, &res, printername, servername); if (!ADS_ERR_OK(rc)) { - d_printf("ads_find_printer_on_server: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_find_printer_on_server: %s\n", ads_errstr(rc)); ads_msgfree(ads, res); ads_destroy(&ads); return -1; } if (ads_count_replies(ads, res) == 0) { - d_printf("Printer '%s' not found\n", printername); + d_fprintf(stderr, "Printer '%s' not found\n", printername); ads_msgfree(ads, res); ads_destroy(&ads); return -1; @@ -1018,7 +1018,7 @@ static int net_ads_printer_publish(int argc, const char **argv) Undefined, NULL); if (NT_STATUS_IS_ERR(nt_status)) { - d_printf("Unable to open a connnection to %s to obtain data " + d_fprintf(stderr, "Unable to open a connnection to %s to obtain data " "for %s\n", servername, printername); ads_destroy(&ads); return -1; @@ -1029,7 +1029,7 @@ static int net_ads_printer_publish(int argc, const char **argv) ads_find_machine_acct(ads, &res, servername); if (ads_count_replies(ads, res) == 0) { - d_printf("Could not find machine account for server %s\n", + d_fprintf(stderr, "Could not find machine account for server %s\n", servername); ads_destroy(&ads); return -1; @@ -1046,7 +1046,7 @@ static int net_ads_printer_publish(int argc, const char **argv) rc = ads_add_printer_entry(ads, prt_dn, mem_ctx, &mods); if (!ADS_ERR_OK(rc)) { - d_printf("ads_publish_printer: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_publish_printer: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } @@ -1082,14 +1082,14 @@ static int net_ads_printer_remove(int argc, const char **argv) rc = ads_find_printer_on_server(ads, &res, argv[0], servername); if (!ADS_ERR_OK(rc)) { - d_printf("ads_find_printer_on_server: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_find_printer_on_server: %s\n", ads_errstr(rc)); ads_msgfree(ads, res); ads_destroy(&ads); return -1; } if (ads_count_replies(ads, res) == 0) { - d_printf("Printer '%s' not found\n", argv[1]); + d_fprintf(stderr, "Printer '%s' not found\n", argv[1]); ads_msgfree(ads, res); ads_destroy(&ads); return -1; @@ -1101,7 +1101,7 @@ static int net_ads_printer_remove(int argc, const char **argv) ads_memfree(ads, prt_dn); if (!ADS_ERR_OK(rc)) { - d_printf("ads_del_dn: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "ads_del_dn: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } @@ -1136,12 +1136,12 @@ static int net_ads_password(int argc, const char **argv) ADS_STATUS ret; if (opt_user_name == NULL || opt_password == NULL) { - d_printf("You must supply an administrator username/password\n"); + d_fprintf(stderr, "You must supply an administrator username/password\n"); return -1; } if (argc < 1) { - d_printf("ERROR: You must say which username to change password for\n"); + d_fprintf(stderr, "ERROR: You must say which username to change password for\n"); return -1; } @@ -1170,7 +1170,7 @@ static int net_ads_password(int argc, const char **argv) ads_connect(ads); if (!ads || !ads->config.realm) { - d_printf("Didn't find the kerberos server!\n"); + d_fprintf(stderr, "Didn't find the kerberos server!\n"); return -1; } @@ -1185,7 +1185,7 @@ static int net_ads_password(int argc, const char **argv) ret = kerberos_set_password(ads->auth.kdc_server, auth_principal, auth_password, user, new_password, ads->auth.time_offset); if (!ADS_ERR_OK(ret)) { - d_printf("Password change failed :-( ...\n"); + d_fprintf(stderr, "Password change failed :-( ...\n"); ads_destroy(&ads); return -1; } @@ -1224,7 +1224,7 @@ int net_ads_changetrustpw(int argc, const char **argv) ret = ads_change_trust_account_password(ads, host_principal); if (!ADS_ERR_OK(ret)) { - d_printf("Password change failed :-( ...\n"); + d_fprintf(stderr, "Password change failed :-( ...\n"); ads_destroy(&ads); SAFE_FREE(host_principal); return -1; @@ -1288,7 +1288,7 @@ static int net_ads_search(int argc, const char **argv) LDAP_SCOPE_SUBTREE, ldap_exp, attrs, &res); if (!ADS_ERR_OK(rc)) { - d_printf("search failed: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "search failed: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } @@ -1348,7 +1348,7 @@ static int net_ads_dn(int argc, const char **argv) LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res); if (!ADS_ERR_OK(rc)) { - d_printf("search failed: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "search failed: %s\n", ads_errstr(rc)); ads_destroy(&ads); return -1; } @@ -1495,7 +1495,7 @@ int net_ads(int argc, const char **argv) static int net_ads_noads(void) { - d_printf("ADS support not compiled in\n"); + d_fprintf(stderr, "ADS support not compiled in\n"); return -1; } diff --git a/source/utils/net_ads_cldap.c b/source/utils/net_ads_cldap.c index 9f70a5b7257..2e7a28b3222 100644 --- a/source/utils/net_ads_cldap.c +++ b/source/utils/net_ads_cldap.c @@ -93,7 +93,7 @@ static unsigned pull_netlogon_string(char *ret, const char *ptr, uint8 len = (uint8)*(ptr++); if ((pret - ret + len + 1) >= MAX_DNS_LABEL) { - d_printf("DC returning too long DNS name\n"); + d_fprintf(stderr, "DC returning too long DNS name\n"); return 0; } @@ -178,13 +178,13 @@ static int send_cldap_netlogon(int sock, const char *domain, asn1_pop_tag(&data); if (data.has_error) { - d_printf("Failed to build cldap netlogon at offset %d\n", (int)data.ofs); + d_fprintf(stderr, "Failed to build cldap netlogon at offset %d\n", (int)data.ofs); asn1_free(&data); return -1; } if (write(sock, data.data, data.length) != (ssize_t)data.length) { - d_printf("failed to send cldap query (%s)\n", strerror(errno)); + d_fprintf(stderr, "failed to send cldap query (%s)\n", strerror(errno)); } asn1_free(&data); @@ -210,7 +210,7 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply) ret = read(sock, blob.data, blob.length); if (ret <= 0) { - d_printf("no reply received to cldap netlogon\n"); + d_fprintf(stderr, "no reply received to cldap netlogon\n"); return -1; } blob.length = ret; @@ -232,7 +232,7 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply) asn1_end_tag(&data); if (data.has_error) { - d_printf("Failed to parse cldap reply\n"); + d_fprintf(stderr, "Failed to parse cldap reply\n"); return -1; } @@ -284,7 +284,7 @@ int ads_cldap_netlogon(ADS_STRUCT *ads) sock = open_udp_socket(target, ads->ldap_port); if (sock == -1) { - d_printf("Failed to open udp socket to %s:%u\n", + d_fprintf(stderr, "Failed to open udp socket to %s:%u\n", inet_ntoa(ads->ldap_ip), ads->ldap_port); return -1; diff --git a/source/utils/net_cache.c b/source/utils/net_cache.c index 6bbab1c8177..0c107a5f01d 100644 --- a/source/utils/net_cache.c +++ b/source/utils/net_cache.c @@ -64,7 +64,7 @@ static void delete_cache_entry(const char* keystr, const char* datastr, const time_t timeout, void* dptr) { if (!gencache_del(keystr)) - d_printf("Couldn't delete entry! key = %s\n", keystr); + d_fprintf(stderr, "Couldn't delete entry! key = %s\n", keystr); } @@ -147,7 +147,7 @@ static int net_cache_add(int argc, const char **argv) /* parse timeout given in command line */ timeout = parse_timeout(timeout_str); if (!timeout) { - d_printf("Invalid timeout argument.\n"); + d_fprintf(stderr, "Invalid timeout argument.\n"); return -1; } @@ -157,7 +157,7 @@ static int net_cache_add(int argc, const char **argv) return 0; } - d_printf("Entry couldn't be added. Perhaps there's already such a key.\n"); + d_fprintf(stderr, "Entry couldn't be added. Perhaps there's already such a key.\n"); gencache_shutdown(); return -1; } @@ -187,7 +187,7 @@ static int net_cache_set(int argc, const char **argv) /* parse timeout given in command line */ timeout = parse_timeout(timeout_str); if (!timeout) { - d_printf("Invalid timeout argument.\n"); + d_fprintf(stderr, "Invalid timeout argument.\n"); return -1; } @@ -197,7 +197,7 @@ static int net_cache_set(int argc, const char **argv) return 0; } - d_printf("Entry couldn't be set. Perhaps there's no such a key.\n"); + d_fprintf(stderr, "Entry couldn't be set. Perhaps there's no such a key.\n"); gencache_shutdown(); return -1; } @@ -223,7 +223,7 @@ static int net_cache_del(int argc, const char **argv) return 0; } - d_printf("Couldn't delete specified entry\n"); + d_fprintf(stderr, "Couldn't delete specified entry\n"); return -1; } @@ -250,7 +250,7 @@ static int net_cache_get(int argc, const char **argv) return 0; } - d_printf("Failed to find entry\n"); + d_fprintf(stderr, "Failed to find entry\n"); return -1; } diff --git a/source/utils/net_rap.c b/source/utils/net_rap.c index 8205fe3fda9..e80beb36456 100644 --- a/source/utils/net_rap.c +++ b/source/utils/net_rap.c @@ -112,7 +112,7 @@ static int rap_file_user(int argc, const char **argv) if (argc == 0) return net_rap_file_usage(argc, argv); - d_printf("net rap file user not implemented yet\n"); + d_fprintf(stderr, "net rap file user not implemented yet\n"); return -1; } diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c index 33eac56a925..0495a7b92c2 100644 --- a/source/utils/net_rpc.c +++ b/source/utils/net_rpc.c @@ -347,7 +347,7 @@ static int net_rpc_oldjoin(int argc, const char **argv) int rc = net_rpc_perform_oldjoin(argc, argv); if (rc) { - d_printf("Failed to join domain\n"); + d_fprintf(stderr, "Failed to join domain\n"); } return rc; @@ -607,7 +607,7 @@ static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid, done: if (!NT_STATUS_IS_OK(result)) { - d_printf("Failed to add user %s - %s\n", acct_name, + d_fprintf(stderr, "Failed to add user %s - %s\n", acct_name, nt_errstr(result)); } else { d_printf("Added user %s\n", acct_name); @@ -714,7 +714,7 @@ static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid, /* Display results */ if (!NT_STATUS_IS_OK(result)) { - d_printf("Failed to delete user account - %s\n", nt_errstr(result)); + d_fprintf(stderr, "Failed to delete user account - %s\n", nt_errstr(result)); } else { d_printf("Deleted user account\n"); } @@ -829,7 +829,7 @@ static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid, done: if (!NT_STATUS_IS_OK(result)) { - d_printf("Failed to rename user from %s to %s - %s\n", old_name, new_name, + d_fprintf(stderr, "Failed to rename user from %s to %s - %s\n", old_name, new_name, nt_errstr(result)); } else { d_printf("Renamed user from %s to %s\n", old_name, new_name); @@ -1280,7 +1280,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, &connect_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Request samr_connect failed\n"); + d_fprintf(stderr, "Request samr_connect failed\n"); goto done; } @@ -1289,7 +1289,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Request open_domain failed\n"); + d_fprintf(stderr, "Request open_domain failed\n"); goto done; } @@ -1299,7 +1299,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, &name_types); if (!NT_STATUS_IS_OK(result)) { - d_printf("Lookup of '%s' failed\n",argv[0]); + d_fprintf(stderr, "Lookup of '%s' failed\n",argv[0]); goto done; } @@ -1310,7 +1310,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, MAXIMUM_ALLOWED_ACCESS, group_rids[0], &group_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Request open_group failed"); + d_fprintf(stderr, "Request open_group failed"); goto done; } @@ -1321,7 +1321,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, &group_attrs); if (!NT_STATUS_IS_OK(result)) { - d_printf("Unable to query group members of %s",argv[0]); + d_fprintf(stderr, "Unable to query group members of %s",argv[0]); goto done; } @@ -1338,7 +1338,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, group_rids[i], &user_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Unable to open group member %d\n",group_rids[i]); + d_fprintf(stderr, "Unable to open group member %d\n",group_rids[i]); goto done; } @@ -1348,7 +1348,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, 21, &user_ctr); if (!NT_STATUS_IS_OK(result)) { - d_printf("Unable to lookup userinfo for group member %d\n",group_rids[i]); + d_fprintf(stderr, "Unable to lookup userinfo for group member %d\n",group_rids[i]); goto done; } @@ -1364,8 +1364,8 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, } if (group_is_primary) { - d_printf("Unable to delete group because some of it's " - "members have it as primary group\n"); + d_fprintf(stderr, "Unable to delete group because some " + "of it's members have it as primary group\n"); result = NT_STATUS_MEMBERS_PRIMARY_GROUP; goto done; } @@ -1397,14 +1397,14 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, group_rids[0], &group_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Request open_alias failed\n"); + d_fprintf(stderr, "Request open_alias failed\n"); goto done; } result = rpccli_samr_delete_dom_alias(pipe_hnd, mem_ctx, &group_pol); break; default: - d_printf("%s is of type %s. This command is only for deleting local or global groups\n", + d_fprintf(stderr, "%s is of type %s. This command is only for deleting local or global groups\n", argv[0],sid_type_lookup(name_types[0])); result = NT_STATUS_UNSUCCESSFUL; goto done; @@ -1415,7 +1415,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, if (opt_verbose) d_printf("Deleted %s '%s'\n",sid_type_lookup(name_types[0]),argv[0]); } else { - d_printf("Deleting of %s failed: %s\n",argv[0], + d_fprintf(stderr, "Deleting of %s failed: %s\n",argv[0], get_friendly_nt_error_msg(result)); } @@ -1482,7 +1482,7 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid, if (NT_STATUS_IS_OK(result)) DEBUG(5, ("add group succeeded\n")); else - d_printf("add group failed: %s\n", nt_errstr(result)); + d_fprintf(stderr, "add group failed: %s\n", nt_errstr(result)); return result; } @@ -1538,7 +1538,7 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid, if (NT_STATUS_IS_OK(result)) DEBUG(5, ("add alias succeeded\n")); else - d_printf("add alias failed: %s\n", nt_errstr(result)); + d_fprintf(stderr, "add alias failed: %s\n", nt_errstr(result)); return result; } @@ -1652,7 +1652,7 @@ static NTSTATUS rpc_add_groupmem(struct rpc_pipe_client *pipe_hnd, &num_rids, &rids, &rid_types); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not lookup up group member %s\n", member); + d_fprintf(stderr, "Could not lookup up group member %s\n", member); goto done; } @@ -1696,7 +1696,7 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd, &member_sid, &member_type); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not lookup up group member %s\n", member); + d_fprintf(stderr, "Could not lookup up group member %s\n", member); return result; } @@ -1752,7 +1752,7 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid, if (!NT_STATUS_IS_OK(get_sid_from_name(cli, mem_ctx, argv[0], &group_sid, &group_type))) { - d_printf("Could not lookup group name %s\n", argv[0]); + d_fprintf(stderr, "Could not lookup group name %s\n", argv[0]); return NT_STATUS_UNSUCCESSFUL; } @@ -1761,7 +1761,7 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid, &group_sid, argv[1]); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not add %s to %s: %s\n", + d_fprintf(stderr, "Could not add %s to %s: %s\n", argv[1], argv[0], nt_errstr(result)); } return result; @@ -1772,14 +1772,14 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid, &group_sid, argv[1]); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not add %s to %s: %s\n", + d_fprintf(stderr, "Could not add %s to %s: %s\n", argv[1], argv[0], nt_errstr(result)); } return result; } - d_printf("Can only add members to global or local groups which " - "%s is not\n", argv[0]); + d_fprintf(stderr, "Can only add members to global or local groups " + "which %s is not\n", argv[0]); return NT_STATUS_UNSUCCESSFUL; } @@ -1830,7 +1830,7 @@ static NTSTATUS rpc_del_groupmem(struct rpc_pipe_client *pipe_hnd, &num_rids, &rids, &rid_types); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not lookup up group member %s\n", member); + d_fprintf(stderr, "Could not lookup up group member %s\n", member); goto done; } @@ -1872,7 +1872,7 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd, &member_sid, &member_type); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not lookup up group member %s\n", member); + d_fprintf(stderr, "Could not lookup up group member %s\n", member); return result; } @@ -1926,7 +1926,7 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid, if (!NT_STATUS_IS_OK(get_sid_from_name(cli, mem_ctx, argv[0], &group_sid, &group_type))) { - d_printf("Could not lookup group name %s\n", argv[0]); + d_fprintf(stderr, "Could not lookup group name %s\n", argv[0]); return NT_STATUS_UNSUCCESSFUL; } @@ -1935,7 +1935,7 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid, &group_sid, argv[1]); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not del %s from %s: %s\n", + d_fprintf(stderr, "Could not del %s from %s: %s\n", argv[1], argv[0], nt_errstr(result)); } return result; @@ -1946,14 +1946,14 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid, &group_sid, argv[1]); if (!NT_STATUS_IS_OK(result)) { - d_printf("Could not del %s from %s: %s\n", + d_fprintf(stderr, "Could not del %s from %s: %s\n", argv[1], argv[0], nt_errstr(result)); } return result; } - d_printf("Can only delete members from global or local groups which " - "%s is not\n", argv[0]); + d_fprintf(stderr, "Can only delete members from global or local groups " + "which %s is not\n", argv[0]); return NT_STATUS_UNSUCCESSFUL; } @@ -2281,7 +2281,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, &num_members, &alias_sids); if (!NT_STATUS_IS_OK(result)) { - d_printf("Couldn't list alias members\n"); + d_fprintf(stderr, "Couldn't list alias members\n"); return result; } @@ -2291,7 +2291,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, lsa_pipe = cli_rpc_pipe_open_noauth(pipe_hnd->cli, PI_LSARPC, &result); if (!lsa_pipe) { - d_printf("Couldn't open LSA pipe. Error was %s\n", + d_fprintf(stderr, "Couldn't open LSA pipe. Error was %s\n", nt_errstr(result) ); return result; } @@ -2300,7 +2300,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Couldn't open LSA policy handle\n"); + d_fprintf(stderr, "Couldn't open LSA policy handle\n"); cli_rpc_pipe_close(lsa_pipe); return result; } @@ -2311,7 +2311,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) { - d_printf("Couldn't lookup SIDs\n"); + d_fprintf(stderr, "Couldn't lookup SIDs\n"); cli_rpc_pipe_close(lsa_pipe); return result; } @@ -2383,7 +2383,7 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid, &sid_Builtin, &domain_pol); if (!NT_STATUS_IS_OK(result)) { - d_printf("Couldn't find group %s\n", argv[0]); + d_fprintf(stderr, "Couldn't find group %s\n", argv[0]); return result; } @@ -2392,13 +2392,13 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid, &rids, &rid_types); if (!NT_STATUS_IS_OK(result)) { - d_printf("Couldn't find group %s\n", argv[0]); + d_fprintf(stderr, "Couldn't find group %s\n", argv[0]); return result; } } if (num_rids != 1) { - d_printf("Couldn't find group %s\n", argv[0]); + d_fprintf(stderr, "Couldn't find group %s\n", argv[0]); return result; } @@ -2466,12 +2466,12 @@ static NTSTATUS rpc_group_rename_internals(const DOM_SID *domain_sid, 1, argv, &num_rids, &rids, &rid_types); if (num_rids != 1) { - d_printf("Couldn't find group %s\n", argv[0]); + d_fprintf(stderr, "Couldn't find group %s\n", argv[0]); return result; } if (rid_types[0] != SID_NAME_DOM_GRP) { - d_printf("Can only rename domain groups\n"); + d_fprintf(stderr, "Can only rename domain groups\n"); return NT_STATUS_UNSUCCESSFUL; } @@ -3057,7 +3057,7 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state False); break; default: - d_printf("Unsupported mode %d\n", net_mode_share); + d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share); return; } @@ -3099,7 +3099,7 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state True); break; default: - d_printf("Unsupported file mode %d\n", net_mode_share); + d_fprintf(stderr, "Unsupported file mode %d\n", net_mode_share); return; } @@ -3124,7 +3124,7 @@ BOOL sync_files(struct copy_clistate *cp_clistate, pstring mask) DEBUG(3,("calling cli_list with mask: %s\n", mask)); if (cli_list(cp_clistate->cli_share_src, mask, cp_clistate->attribute, copy_fn, cp_clistate) == -1) { - d_printf("listing %s failed with error: %s\n", + d_fprintf(stderr, "listing %s failed with error: %s\n", mask, cli_errstr(cp_clistate->cli_share_src)); return False; } @@ -3156,7 +3156,7 @@ BOOL copy_top_level_perms(struct copy_clistate *cp_clistate, False); break; default: - d_printf("Unsupported mode %d\n", net_mode_share); + d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share); break; } @@ -3233,7 +3233,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid, printf("syncing"); break; default: - d_printf("Unsupported mode %d\n", net_mode_share); + d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share); break; } printf(" [%s] files and directories %s ACLs, %s DOS Attributes %s\n", @@ -3268,13 +3268,13 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid, } if (!copy_top_level_perms(&cp_clistate, netname)) { - d_printf("Could not handle the top level directory permissions for the share: %s\n", netname); + d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", netname); nt_status = NT_STATUS_UNSUCCESSFUL; goto done; } if (!sync_files(&cp_clistate, mask)) { - d_printf("could not handle files for share: %s\n", netname); + d_fprintf(stderr, "could not handle files for share: %s\n", netname); nt_status = NT_STATUS_UNSUCCESSFUL; goto done; } @@ -3878,8 +3878,8 @@ static BOOL get_user_tokens(int *num_tokens, struct user_token **user_tokens) if (lp_winbind_use_default_domain() && (opt_target_workgroup == NULL)) { - d_printf("winbind use default domain = yes set, please " - "specify a workgroup\n"); + d_fprintf(stderr, "winbind use default domain = yes set, " + "please specify a workgroup\n"); return False; } @@ -4681,11 +4681,11 @@ static NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid, if (W_ERROR_IS_OK(result)) { d_printf("\nShutdown of remote machine succeeded\n"); } else { - d_printf("\nShutdown of remote machine failed\n"); + d_fprintf(stderr, "\nShutdown of remote machine failed\n"); if (W_ERROR_EQUAL(result,WERR_MACHINE_LOCKED)) - d_printf("\nMachine locked, use -f switch to force\n"); + d_fprintf(stderr, "\nMachine locked, use -f switch to force\n"); else - d_printf("\nresult was: %s\n", dos_errstr(result)); + d_fprintf(stderr, "\nresult was: %s\n", dos_errstr(result)); } return werror_to_ntstatus(result); @@ -5293,8 +5293,10 @@ static NTSTATUS vampire_trusted_domain(struct rpc_pipe_client *pipe_hnd, goto done; } +#ifdef DEBUG_PASSWORD DEBUG(100,("sucessfully vampired trusted domain [%s], sid: [%s], password: [%s]\n", trusted_dom_name, sid_string_static(&dom_sid), cleartextpwd)); +#endif done: SAFE_FREE(cleartextpwd); @@ -5632,12 +5634,12 @@ static int rpc_trustdom_list(int argc, const char **argv) if (remote_cli) { /* query for domain's sid */ if (run_rpc_command(remote_cli, PI_LSARPC, 0, rpc_query_domain_sid, argc, argv)) - d_printf("couldn't get domain's sid\n"); + d_fprintf(stderr, "couldn't get domain's sid\n"); cli_shutdown(remote_cli); } else { - d_printf("domain controller is not responding\n"); + d_fprintf(stderr, "domain controller is not responding\n"); }; }; diff --git a/source/utils/net_rpc_join.c b/source/utils/net_rpc_join.c index 12e51a85d17..6a5a7559c3a 100644 --- a/source/utils/net_rpc_join.c +++ b/source/utils/net_rpc_join.c @@ -202,14 +202,14 @@ int net_rpc_join_newstyle(int argc, const char **argv) if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, NT_STATUS_USER_EXISTS)) { - d_printf("Creation of workstation account failed\n"); + d_fprintf(stderr, "Creation of workstation account failed\n"); /* If NT_STATUS_ACCESS_DENIED then we have a valid username/password combo but the user does not have administrator access. */ if (NT_STATUS_V(result) == NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) - d_printf("User specified does not have administrator privileges\n"); + d_fprintf(stderr, "User specified does not have administrator privileges\n"); goto done; } @@ -317,7 +317,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) if ( NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED) && (sec_channel_type == SEC_CHAN_BDC) ) { - d_printf("Please make sure that no computer account\n" + d_fprintf(stderr, "Please make sure that no computer account\n" "named like this machine (%s) exists in the domain\n", global_myname()); } @@ -338,7 +338,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) if ( NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED) && (sec_channel_type == SEC_CHAN_BDC) ) { - d_printf("Please make sure that no computer account\n" + d_fprintf(stderr, "Please make sure that no computer account\n" "named like this machine (%s) exists in the domain\n", global_myname()); } diff --git a/source/utils/net_rpc_printer.c b/source/utils/net_rpc_printer.c index d8f3099dec8..5e282403a24 100644 --- a/source/utils/net_rpc_printer.c +++ b/source/utils/net_rpc_printer.c @@ -403,14 +403,14 @@ NTSTATUS net_copy_fileattr(TALLOC_CTX *mem_ctx, /* closing files */ if (!cli_close(cli_share_src, fnum_src)) { - d_printf("could not close %s on originating server: %s\n", + d_fprintf(stderr, "could not close %s on originating server: %s\n", is_file?"file":"dir", cli_errstr(cli_share_src)); nt_status = cli_nt_error(cli_share_src); goto out; } if (!cli_close(cli_share_dst, fnum_dst)) { - d_printf("could not close %s on destination server: %s\n", + d_fprintf(stderr, "could not close %s on destination server: %s\n", is_file?"file":"dir", cli_errstr(cli_share_dst)); nt_status = cli_nt_error(cli_share_dst); goto out; @@ -504,7 +504,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx, /* allocate memory */ if (!(data = (char *)SMB_MALLOC(read_size))) { - d_printf("malloc fail for size %d\n", read_size); + d_fprintf(stderr, "malloc fail for size %d\n", read_size); nt_status = NT_STATUS_NO_MEMORY; goto out; } @@ -538,7 +538,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx, nread + start, n); if (n != ret) { - d_printf("Error writing file: %s\n", + d_fprintf(stderr, "Error writing file: %s\n", cli_errstr(cli_share_dst)); nt_status = cli_nt_error(cli_share_dst); goto out; @@ -561,7 +561,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx, } if (!cli_chkpath(cli_share_dst, dst_name)) { - d_printf("cannot check for directory %s: %s\n", + d_fprintf(stderr, "cannot check for directory %s: %s\n", dst_name, cli_errstr(cli_share_dst)); goto out; } @@ -570,14 +570,14 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx, /* closing files */ if (!cli_close(cli_share_src, fnum_src)) { - d_printf("could not close file on originating server: %s\n", + d_fprintf(stderr, "could not close file on originating server: %s\n", cli_errstr(cli_share_src)); nt_status = cli_nt_error(cli_share_src); goto out; } if (is_file && !cli_close(cli_share_dst, fnum_dst)) { - d_printf("could not close file on destination server: %s\n", + d_fprintf(stderr, "could not close file on destination server: %s\n", cli_errstr(cli_share_dst)); nt_status = cli_nt_error(cli_share_dst); goto out; @@ -704,7 +704,7 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar } if (!cli_chkpath(cli_share, dir)) { - d_printf("cannot check %s: %s\n", + d_fprintf(stderr, "cannot check %s: %s\n", dir, cli_errstr(cli_share)); goto out; } @@ -859,13 +859,13 @@ static BOOL net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, /* be more verbose */ if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) { - d_printf("no access to printer [%s] on [%s] for user [%s] granted\n", + d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n", printername2, servername, username); return False; } if (!W_ERROR_IS_OK(result)) { - d_printf("cannot open printer %s on server %s: %s\n", + d_fprintf(stderr, "cannot open printer %s on server %s: %s\n", printername2, servername, dos_errstr(result)); return False; } @@ -2134,9 +2134,9 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid, if (W_ERROR_IS_OK(result)) d_printf ("printer [%s] successfully added.\n", printername); else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS)) - d_printf ("printer [%s] already exists.\n", printername); + d_fprintf (stderr, "printer [%s] already exists.\n", printername); else { - printf ("could not create printer\n"); + d_fprintf (stderr, "could not create printer [%s]\n", printername); goto done; } diff --git a/source/utils/net_rpc_registry.c b/source/utils/net_rpc_registry.c index 289fb59fea3..9852fe4a94f 100644 --- a/source/utils/net_rpc_registry.c +++ b/source/utils/net_rpc_registry.c @@ -105,7 +105,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, } if ( !reg_split_hive( argv[0], &hive, subpath ) ) { - d_printf("invalid registry path\n"); + d_fprintf(stderr, "invalid registry path\n"); return NT_STATUS_OK; } @@ -113,18 +113,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid, result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to connect to remote registry\n"); + d_fprintf(stderr, "Unable to connect to remote registry\n"); return werror_to_ntstatus(result); } if ( strlen( subpath ) != 0 ) { result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to open [%s]\n", argv[0]); + d_fprintf(stderr, "Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); } } - memcpy( &pol_key, &pol_hive, sizeof(POLICY_HND) ); /* get the subkeys */ @@ -224,7 +223,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, } if ( !reg_split_hive( argv[0], &hive, subpath ) ) { - d_printf("invalid registry path\n"); + d_fprintf(stderr, "invalid registry path\n"); return NT_STATUS_OK; } @@ -232,19 +231,19 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid, result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to connect to remote registry\n"); + d_fprintf(stderr, "Unable to connect to remote registry\n"); return werror_to_ntstatus(result); } result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to open [%s]\n", argv[0]); + d_fprintf(stderr, "Unable to open [%s]\n", argv[0]); return werror_to_ntstatus(result); } result = rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); + d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]); } @@ -330,7 +329,7 @@ static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa d_printf("\n"); dump_registry_tree( file, key, regpath ); } - + return True; } @@ -402,7 +401,7 @@ static int rpc_registry_dump( int argc, const char **argv ) d_printf("Opening %s....", argv[0]); if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) { - d_printf("Failed to open %s for reading\n", argv[0]); + d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]); return 1; } d_printf("ok\n"); @@ -433,6 +432,7 @@ static int rpc_registry_copy( int argc, const char **argv ) { REGF_FILE *infile, *outfile; REGF_NK_REC *nk; + int result = 1; if (argc != 2 ) { d_printf("Usage: net rpc copy <srcfile> <newfile>\n"); @@ -441,15 +441,15 @@ static int rpc_registry_copy( int argc, const char **argv ) d_printf("Opening %s....", argv[0]); if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) { - d_printf("Failed to open %s for reading\n", argv[0]); + d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]); return 1; } d_printf("ok\n"); d_printf("Opening %s....", argv[1]); if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) { - d_printf("Failed to open %s for writing\n", argv[1]); - return 1; + d_fprintf(stderr, "Failed to open %s for writing\n", argv[1]); + goto out_close_infile; } d_printf("ok\n"); @@ -460,15 +460,18 @@ static int rpc_registry_copy( int argc, const char **argv ) write_registry_tree( infile, nk, NULL, outfile, "" ); + result = 0; + d_printf("Closing %s...", argv[1]); regfio_close( outfile ); d_printf("ok\n"); +out_close_infile: d_printf("Closing %s...", argv[0]); regfio_close( infile ); d_printf("ok\n"); - return 0; + return( result); } /******************************************************************** diff --git a/source/utils/net_rpc_rights.c b/source/utils/net_rpc_rights.c index a563475ee10..2c15fef5a09 100644 --- a/source/utils/net_rpc_rights.c +++ b/source/utils/net_rpc_rights.c @@ -335,15 +335,15 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid, if ( !NT_STATUS_IS_OK(result) ) { if ( NT_STATUS_EQUAL( result, NT_STATUS_NO_SUCH_PRIVILEGE ) ) - d_printf("No such privilege exists: %s.\n", privname); + d_fprintf(stderr, "No such privilege exists: %s.\n", privname); else - d_printf("Error resolving privilege display name [%s].\n", nt_errstr(result)); + d_fprintf(stderr, "Error resolving privilege display name [%s].\n", nt_errstr(result)); continue; } result = enum_accounts_for_privilege(pipe_hnd, mem_ctx, &pol, privname); if (!NT_STATUS_IS_OK(result)) { - d_printf("Error enumerating accounts for privilege %s [%s].\n", + d_fprintf(stderr, "Error enumerating accounts for privilege %s [%s].\n", privname, nt_errstr(result)); continue; } @@ -437,7 +437,7 @@ static NTSTATUS rpc_rights_grant_internal(const DOM_SID *domain_sid, done: if ( !NT_STATUS_IS_OK(result) ) { - d_printf("Failed to grant privileges for %s (%s)\n", + d_fprintf(stderr, "Failed to grant privileges for %s (%s)\n", argv[0], nt_errstr(result)); } @@ -488,7 +488,7 @@ static NTSTATUS rpc_rights_revoke_internal(const DOM_SID *domain_sid, done: if ( !NT_STATUS_IS_OK(result) ) { - d_printf("Failed to revoke privileges for %s (%s)", + d_fprintf(stderr, "Failed to revoke privileges for %s (%s)", argv[0], nt_errstr(result)); } diff --git a/source/utils/net_rpc_samsync.c b/source/utils/net_rpc_samsync.c index f4a0ab90e8f..09e62d9defa 100644 --- a/source/utils/net_rpc_samsync.c +++ b/source/utils/net_rpc_samsync.c @@ -536,7 +536,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) /* try and find the possible unix account again */ if ( !(passwd = Get_Pwnam(account)) ) { - d_printf("Could not create posix account info for '%s'\n", account); + d_fprintf(stderr, "Could not create posix account info for '%s'\n", account); nt_ret = NT_STATUS_NO_SUCH_USER; goto done; } @@ -1847,7 +1847,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, const char *add_ldif = "/tmp/add.ldif", *mod_ldif = "/tmp/mod.ldif"; FILE *add_fd, *mod_fd, *ldif_fd; char sys_cmd[1024]; - int num_alloced = 0, g_index = 0, a_index = 0; + int num_alloced = 0, g_index = 0, a_index = 0, sys_cmd_result; /* Set up array for mapping accounts to groups */ /* Array element is the group rid */ @@ -2068,7 +2068,12 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, fflush(ldif_fd); } pstr_sprintf(sys_cmd, "cat %s >> %s", add_ldif, ldif_file); - system(sys_cmd); + sys_cmd_result = system(sys_cmd); + if (sys_cmd_result) { + d_fprintf(stderr, "%s failed. Error was (%s)\n", + sys_cmd, strerror(errno)); + return NT_STATUS_UNSUCCESSFUL; + } if (db_type == SAM_DATABASE_DOMAIN) { fprintf(ldif_fd, "# SAM_DATABASE_DOMAIN: MODIFY ENTITIES\n"); @@ -2083,11 +2088,21 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, fflush(ldif_fd); } pstr_sprintf(sys_cmd, "cat %s >> %s", mod_ldif, ldif_file); - system(sys_cmd); + sys_cmd_result = system(sys_cmd); + if (sys_cmd_result) { + d_fprintf(stderr, "%s failed. Error was (%s)\n", + sys_cmd, strerror(errno)); + return NT_STATUS_UNSUCCESSFUL; + } /* Delete the temporary ldif files */ pstr_sprintf(sys_cmd, "rm -f %s %s", add_ldif, mod_ldif); - system(sys_cmd); + sys_cmd_result = system(sys_cmd); + if (sys_cmd_result) { + d_fprintf(stderr, "%s failed. Error was (%s)\n", + sys_cmd, strerror(errno)); + return NT_STATUS_UNSUCCESSFUL; + } /* Close the ldif file */ fclose(ldif_fd); @@ -2154,11 +2169,11 @@ NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid, } if (!NT_STATUS_IS_OK(result)) { - d_printf("Failed to fetch domain database: %s\n", + d_fprintf(stderr, "Failed to fetch domain database: %s\n", nt_errstr(result)); if (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) - d_printf("Perhaps %s is a Windows 2000 native mode " - "domain?\n", domain_name); + d_fprintf(stderr, "Perhaps %s is a Windows 2000 native " + "mode domain?\n", domain_name); goto fail; } @@ -2170,7 +2185,7 @@ NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid, } if (!NT_STATUS_IS_OK(result)) { - d_printf("Failed to fetch builtin database: %s\n", + d_fprintf(stderr, "Failed to fetch builtin database: %s\n", nt_errstr(result)); goto fail; } diff --git a/source/utils/net_rpc_service.c b/source/utils/net_rpc_service.c index ed7d1dfab1f..27127a1c3f9 100644 --- a/source/utils/net_rpc_service.c +++ b/source/utils/net_rpc_service.c @@ -40,7 +40,7 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd, service, SC_RIGHT_SVC_QUERY_STATUS ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open service. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); return result; } @@ -110,7 +110,7 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd, service, (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE) ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open service. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } @@ -120,7 +120,7 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd, control, &service_status ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Control service request failed. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Control service request failed. [%s]\n", dos_errstr(result)); goto done; } @@ -162,7 +162,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -170,7 +170,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, SVCCTL_STATE_ALL, &num_services, &services ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to enumerate services. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to enumerate services. [%s]\n", dos_errstr(result)); goto done; } @@ -219,7 +219,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -229,7 +229,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, (SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG) ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open service. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } @@ -237,7 +237,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, &hService, &service_status ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Query status request failed. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result)); goto done; } @@ -247,7 +247,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_query_config(pipe_hnd, mem_ctx, &hService, &config ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Query config request failed. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Query config request failed. [%s]\n", dos_errstr(result)); goto done; } @@ -318,7 +318,7 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -356,7 +356,7 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -394,7 +394,7 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -433,7 +433,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result)); return werror_to_ntstatus(result); } @@ -443,7 +443,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, servicename, SC_RIGHT_SVC_START ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Failed to open service. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result)); goto done; } @@ -451,7 +451,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, result = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, &hService, NULL, 0 ); if ( !W_ERROR_IS_OK(result) ) { - d_printf("Query status request failed. [%s]\n", dos_errstr(result)); + d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result)); goto done; } @@ -460,7 +460,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) ) d_printf("Successfully started service: %s\n", servicename ); else - d_printf("Failed to start service: %s [%s]\n", servicename, dos_errstr(result) ); + d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) ); done: rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService ); diff --git a/source/utils/net_status.c b/source/utils/net_status.c index 31693affe73..d3b1bae276d 100644 --- a/source/utils/net_status.c +++ b/source/utils/net_status.c @@ -74,7 +74,7 @@ static int net_status_sessions(int argc, const char **argv) TDB_DEFAULT, O_RDONLY, 0); if (tdb == NULL) { - d_printf("%s not initialised\n", lock_path("sessionid.tdb")); + d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); return -1; } @@ -186,7 +186,7 @@ static int net_status_shares_parseable(int argc, const char **argv) TDB_DEFAULT, O_RDONLY, 0); if (tdb == NULL) { - d_printf("%s not initialised\n", lock_path("sessionid.tdb")); + d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb")); return -1; } @@ -197,9 +197,9 @@ static int net_status_shares_parseable(int argc, const char **argv) TDB_DEFAULT, O_RDONLY, 0); if (tdb == NULL) { - d_printf("%s not initialised\n", lock_path("connections.tdb")); - d_printf("This is normal if no SMB client has ever connected " - "to your server.\n"); + d_fprintf(stderr, "%s not initialised\n", lock_path("connections.tdb")); + d_fprintf(stderr, "This is normal if no SMB client has ever " + "connected to your server.\n"); return -1; } @@ -226,10 +226,10 @@ static int net_status_shares(int argc, const char **argv) TDB_DEFAULT, O_RDONLY, 0); if (tdb == NULL) { - d_printf("%s not initialised\n", + d_fprintf(stderr, "%s not initialised\n", lock_path("connections.tdb")); - d_printf("This is normal if no SMB client has ever " - "connected to your server.\n"); + d_fprintf(stderr, "This is normal if no SMB client has " + "ever connected to your server.\n"); return -1; } diff --git a/source/utils/net_time.c b/source/utils/net_time.c index 691adcea00e..1a7116d447d 100644 --- a/source/utils/net_time.c +++ b/source/utils/net_time.c @@ -99,6 +99,7 @@ static int net_time_set(int argc, const char **argv) { time_t t = nettime(NULL); char *cmd; + int result; if (t == 0) return -1; @@ -106,10 +107,13 @@ static int net_time_set(int argc, const char **argv) roll your own. I'm putting this in as it works on a large number of systems and the user has a choice in whether its used or not */ asprintf(&cmd, "/bin/date %s", systime(t)); - system(cmd); + result = system(cmd); + if (result) + d_fprintf(stderr, "%s failed. Error was (%s)\n", + cmd, strerror(errno)); free(cmd); - return 0; + return result; } /* display the time on a remote box in a format ready for /bin/date */ @@ -161,7 +165,7 @@ int net_time(int argc, const char **argv) if (!opt_host && !opt_have_ip && !find_master_ip(opt_target_workgroup, &opt_dest_ip)) { - d_printf("Could not locate a time server. Try "\ + d_fprintf(stderr, "Could not locate a time server. Try "\ "specifying a target host.\n"); net_time_usage(argc,argv); return -1; diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c index 09148ad37c3..e88d7862901 100644 --- a/source/utils/nmblookup.c +++ b/source/utils/nmblookup.c @@ -214,6 +214,8 @@ int main(int argc,char *argv[]) *lookup = 0; + load_case_tables(); + setup_logging(argv[0],True); pc = poptGetContext("nmblookup", argc, (const char **)argv, long_options, diff --git a/source/utils/ntlm_auth.c b/source/utils/ntlm_auth.c index 433ba069824..65dbfb71650 100644 --- a/source/utils/ntlm_auth.c +++ b/source/utils/ntlm_auth.c @@ -1752,6 +1752,7 @@ enum { }; /* Samba client initialisation */ + load_case_tables(); dbf = x_stderr; diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c index 9c292bd212a..ddf0eea169b 100644 --- a/source/utils/pdbedit.c +++ b/source/utils/pdbedit.c @@ -775,6 +775,8 @@ int main (int argc, char **argv) POPT_TABLEEND }; + load_case_tables(); + setup_logging("pdbedit", True); pc = poptGetContext(NULL, argc, (const char **) argv, long_options, diff --git a/source/utils/smbcacls.c b/source/utils/smbcacls.c index fd1d3cbf89c..cbbd7adaab3 100644 --- a/source/utils/smbcacls.c +++ b/source/utils/smbcacls.c @@ -818,6 +818,8 @@ static struct cli_state *connect_one(const char *share) struct cli_state *cli; + load_case_tables(); + ctx=talloc_init("main"); /* set default debug level to 1 regardless of what smb.conf sets */ diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c index 25b42a58c1e..b8f7c2f2b55 100644 --- a/source/utils/smbcontrol.c +++ b/source/utils/smbcontrol.c @@ -786,6 +786,8 @@ int main(int argc, const char **argv) POPT_TABLEEND }; + load_case_tables(); + setup_logging(argv[0],True); /* Parse command line arguments using popt */ diff --git a/source/utils/smbcquotas.c b/source/utils/smbcquotas.c index c516fbb2187..f8e33131555 100644 --- a/source/utils/smbcquotas.c +++ b/source/utils/smbcquotas.c @@ -396,7 +396,7 @@ static struct cli_state *connect_one(const char *share) pstring username_str = {0}; pstring path = {0}; pstring set_str = {0}; - enum SMB_QUOTA_TYPE qtype; + enum SMB_QUOTA_TYPE qtype = SMB_INVALID_QUOTA_TYPE; int cmd = 0; static BOOL test_args = False; struct cli_state *cli; @@ -421,6 +421,8 @@ FSQFLAGS:QUOTA_ENABLED/DENY_DISK/LOG_SOFTLIMIT/LOG_HARD_LIMIT", "SETSTRING" }, { NULL } }; + load_case_tables(); + ZERO_STRUCT(qt); /* set default debug level to 1 regardless of what smb.conf sets */ diff --git a/source/utils/smbtree.c b/source/utils/smbtree.c index 00f6a74f2f2..3755b7f8e55 100644 --- a/source/utils/smbtree.c +++ b/source/utils/smbtree.c @@ -203,6 +203,7 @@ static BOOL print_tree(struct user_auth_info *user_info) poptContext pc; /* Initialise samba stuff */ + load_case_tables(); setlinebuf(stdout); diff --git a/source/utils/status.c b/source/utils/status.c index a495d07f047..eeaf83d1772 100644 --- a/source/utils/status.c +++ b/source/utils/status.c @@ -98,18 +98,18 @@ static BOOL Ucrit_addPid( pid_t pid ) return True; } -static void print_share_mode(const struct share_mode_entry *e, char *fname) +static void print_share_mode(const struct share_mode_entry *e, const char *sharepath, const char *fname) { static int count; if (count==0) { d_printf("Locked files:\n"); - d_printf("Pid DenyMode Access R/W Oplock Name\n"); - d_printf("--------------------------------------------------------------\n"); + d_printf("Pid DenyMode Access R/W Oplock SharePath Name\n"); + d_printf("----------------------------------------------------------------------------------------\n"); } count++; if (Ucrit_checkPid(procid_to_pid(&e->pid))) { - d_printf("%s ",procid_str_static(&e->pid)); + d_printf("%-11s ",procid_str_static(&e->pid)); switch (map_share_mode_to_deny_mode(e->share_access, e->private_options)) { case DENY_NONE: d_printf("DENY_NONE "); break; @@ -150,7 +150,7 @@ static void print_share_mode(const struct share_mode_entry *e, char *fname) d_printf("NONE "); } - d_printf(" %s %s",fname, asctime(localtime((time_t *)&e->time.tv_sec))); + d_printf(" %s %s %s",sharepath, fname, asctime(localtime((time_t *)&e->time.tv_sec))); } } @@ -166,7 +166,7 @@ static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid, } count++; - d_printf("%s %05x:%05x %s %9.0f %9.0f\n", + d_printf("%8s %05x:%05x %s %9.0f %9.0f\n", procid_str_static(&pid), (int)dev, (int)ino, lock_type==READ_LOCK?"R":"W", (double)start, (double)size); @@ -613,6 +613,8 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo POPT_TABLEEND }; + load_case_tables(); + setup_logging(argv[0],True); dbf = x_stderr; diff --git a/source/utils/testparm.c b/source/utils/testparm.c index 0ce838e5c76..f5c835725a4 100644 --- a/source/utils/testparm.c +++ b/source/utils/testparm.c @@ -230,6 +230,8 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ POPT_TABLEEND }; + load_case_tables(); + pc = poptGetContext(NULL, argc, argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "[OPTION...] <config-file> [host-name] [host-ip]"); @@ -348,24 +350,7 @@ print command parameter is ignored when using CUPS libraries.\n", if (!silent_mode && !section_name && !parameter_name) { - fprintf(stderr,"Server role: "); - switch(lp_server_role()) { - case ROLE_STANDALONE: - fprintf(stderr,"ROLE_STANDALONE\n"); - break; - case ROLE_DOMAIN_MEMBER: - fprintf(stderr,"ROLE_DOMAIN_MEMBER\n"); - break; - case ROLE_DOMAIN_BDC: - fprintf(stderr,"ROLE_DOMAIN_BDC\n"); - break; - case ROLE_DOMAIN_PDC: - fprintf(stderr,"ROLE_DOMAIN_PDC\n"); - break; - default: - fprintf(stderr,"Unknown -- internal error?\n"); - break; - } + fprintf(stderr,"Server role: %s\n", server_role_str(lp_server_role())); } if (!cname) { diff --git a/source/web/swat.c b/source/web/swat.c index 15612484a35..3806291a6ad 100644 --- a/source/web/swat.c +++ b/source/web/swat.c @@ -103,7 +103,7 @@ static char *stripspaceupper(const char *str) char *p = newstring; while (*str) { - if (*str != ' ') *p++ = toupper(*str); + if (*str != ' ') *p++ = toupper_ascii(*str); ++str; } *p = '\0'; |