diff options
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/ldap.c | 26 | ||||
-rw-r--r-- | source3/passdb/nispass.c | 22 | ||||
-rw-r--r-- | source3/passdb/pampass.c | 29 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 142 | ||||
-rw-r--r-- | source3/passdb/pdb_ldap.c | 12 | ||||
-rw-r--r-- | source3/passdb/pdb_nisplus.c | 28 | ||||
-rw-r--r-- | source3/passdb/pdb_smbpasswd.c | 16 | ||||
-rw-r--r-- | source3/passdb/pdb_tdb.c | 38 |
8 files changed, 128 insertions, 185 deletions
diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c index 753663a09c..e0ac013fc8 100644 --- a/source3/passdb/ldap.c +++ b/source3/passdb/ldap.c @@ -77,7 +77,7 @@ static BOOL ldap_connect_system(LDAP *ldap_struct) /******************************************************************* connect to the ldap server under a particular user. ******************************************************************/ -static BOOL ldap_connect_user(LDAP *ldap_struct, char *user, char *password) +static BOOL ldap_connect_user(LDAP *ldap_struct, const char *user, const char *password) { if ( ldap_simple_bind_s(ldap_struct,lp_ldap_root(),lp_ldap_rootpasswd()) ! = LDAP_SUCCESS) { @@ -111,7 +111,7 @@ static BOOL ldap_search_one_user(LDAP *ldap_struct, char *filter, LDAPMessage ** /******************************************************************* run the search by name. ******************************************************************/ -static BOOL ldap_search_one_user_by_name(LDAP *ldap_struct, char *user, LDAPMessage **result) +static BOOL ldap_search_one_user_by_name(LDAP *ldap_struct, const char *user, LDAPMessage **result) { pstring filter; /* @@ -374,7 +374,7 @@ static void ldap_get_sam_passwd(LDAP *ldap_struct, LDAPMessage *entry, manage memory used by the array, by each struct, and values ************************************************************************/ -static void make_a_mod(LDAPMod ***modlist,int modop, char *attribute, char *value) +static void make_a_mod(LDAPMod ***modlist,int modop, const char *attribute, const char *value) { LDAPMod **mods, **tmods; int i; @@ -980,21 +980,6 @@ static BOOL del_ldappwd_entry(const char *name) return False; /* Dummy... */ } -static struct sam_disp_info *getldapdispnam(char *name) -{ - return pdb_sam_to_dispinfo(getldap21pwnam(name)); -} - -static struct sam_disp_info *getldapdisprid(uint32 rid) -{ - return pdb_sam_to_dispinfo(getldap21pwrid(rid)); -} - -static struct sam_disp_info *getldapdispent(void *vp) -{ - return pdb_sam_to_dispinfo(getldap21pwent(vp)); -} - static struct sam_passwd *getldap21pwuid(uid_t uid) { return pdb_smb_to_sam(iterate_getsam21pwuid(pdb_uid_to_user_rid(uid))); @@ -1018,10 +1003,7 @@ static struct passdb_ops ldap_ops = iterate_getsam21pwuid, /* From passdb.c */ iterate_getsam21pwrid, /* From passdb.c */ add_ldap21pwd_entry, - mod_ldap21pwd_entry, - getldapdispnam, - getldapdisprid, - getldapdispent + mod_ldap21pwd_entry }; struct passdb_ops *ldap_initialize_password_db(void) diff --git a/source3/passdb/nispass.c b/source3/passdb/nispass.c index a595cabb37..79465982ec 100644 --- a/source3/passdb/nispass.c +++ b/source3/passdb/nispass.c @@ -504,7 +504,7 @@ static BOOL setnisppwpos(void *vp, SMB_BIG_UINT tok) sets a NIS+ attribute *************************************************************************/ static void set_single_attribute(nis_object *new_obj, int col, - char *val, int len, int flags) + const char *val, int len, int flags) { if (new_obj == NULL) return; @@ -1031,21 +1031,6 @@ static struct smb_passwd *getnisppwuid(uid_t smb_userid) return pdb_sam_to_smb(getnisp21pwuid(smb_userid)); } -static struct sam_disp_info *getnispdispnam(char *name) -{ - return pdb_sam_to_dispinfo(getnisp21pwnam(name)); -} - -static struct sam_disp_info *getnispdisprid(uint32 rid) -{ - return pdb_sam_to_dispinfo(getnisp21pwrid(rid)); -} - -static struct sam_disp_info *getnispdispent(void *vp) -{ - return pdb_sam_to_dispinfo(getnisp21pwent(vp)); -} - static struct passdb_ops nispasswd_ops = { startnisppwent, endnisppwent, @@ -1063,10 +1048,7 @@ static struct passdb_ops nispasswd_ops = { getnisp21pwuid, getnisp21pwrid, add_nisp21pwd_entry, - mod_nisp21pwd_entry, - getnispdispnam, - getnispdisprid, - getnispdispent + mod_nisp21pwd_entry }; struct passdb_ops *nisplus_initialize_password_db(void) diff --git a/source3/passdb/pampass.c b/source3/passdb/pampass.c index 0c7c4f1291..6980b14f46 100644 --- a/source3/passdb/pampass.c +++ b/source3/passdb/pampass.c @@ -47,9 +47,9 @@ */ struct smb_pam_userdata { - char *PAM_username; - char *PAM_password; - char *PAM_newpassword; + const char *PAM_username; + const char *PAM_password; + const char *PAM_newpassword; }; typedef int (*smb_pam_conv_fn)(int, const struct pam_message **, struct pam_response **, void *appdata_ptr); @@ -180,7 +180,7 @@ static void special_char_sub(char *buf) all_string_sub(buf, "\\t", "\t", 0); } -static void pwd_sub(char *buf, char *username, char *oldpass, char *newpass) +static void pwd_sub(char *buf, const char *username, const char *oldpass, const char *newpass) { pstring_sub(buf, "%u", username); all_string_sub(buf, "%o", oldpass, sizeof(fstring)); @@ -399,8 +399,8 @@ static void smb_free_pam_conv(struct pam_conv *pconv) Allocate a pam_conv struct. ****************************************************************************/ -static struct pam_conv *smb_setup_pam_conv(smb_pam_conv_fn smb_pam_conv_fnptr, char *user, - char *passwd, char *newpass) +static struct pam_conv *smb_setup_pam_conv(smb_pam_conv_fn smb_pam_conv_fnptr, const char *user, + const char *passwd, const char *newpass) { struct pam_conv *pconv = (struct pam_conv *)malloc(sizeof(struct pam_conv)); struct smb_pam_userdata *udp = (struct smb_pam_userdata *)malloc(sizeof(struct smb_pam_userdata)); @@ -445,9 +445,10 @@ static BOOL smb_pam_end(pam_handle_t *pamh, struct pam_conv *smb_pam_conv_ptr) * Start PAM authentication for specified account */ -static BOOL smb_pam_start(pam_handle_t **pamh, char *user, char *rhost, struct pam_conv *pconv) +static BOOL smb_pam_start(pam_handle_t **pamh, const char *user, const char *rhost, struct pam_conv *pconv) { int pam_error; + const char *our_rhost; *pamh = (pam_handle_t *)NULL; @@ -460,14 +461,16 @@ static BOOL smb_pam_start(pam_handle_t **pamh, char *user, char *rhost, struct p } if (rhost == NULL) { - rhost = client_name(); + our_rhost = client_name(); if (strequal(rhost,"UNKNOWN")) - rhost = client_addr(); + our_rhost = client_addr(); + } else { + our_rhost = rhost; } #ifdef PAM_RHOST - DEBUG(4,("smb_pam_start: PAM: setting rhost to: %s\n", rhost)); - pam_error = pam_set_item(*pamh, PAM_RHOST, rhost); + DEBUG(4,("smb_pam_start: PAM: setting rhost to: %s\n", our_rhost)); + pam_error = pam_set_item(*pamh, PAM_RHOST, our_rhost); if(!smb_pam_error_handler(*pamh, pam_error, "set rhost failed", 0)) { smb_pam_end(*pamh, pconv); *pamh = (pam_handle_t *)NULL; @@ -664,7 +667,7 @@ static BOOL smb_internal_pam_session(pam_handle_t *pamh, char *user, char *tty, * Internal PAM Password Changer. */ -static BOOL smb_pam_chauthtok(pam_handle_t *pamh, char * user) +static BOOL smb_pam_chauthtok(pam_handle_t *pamh, const char * user) { int pam_error; @@ -846,7 +849,7 @@ NTSTATUS smb_pam_passcheck(char * user, char * password) * PAM Password Change Suite */ -BOOL smb_pam_passchange(char * user, char * oldpassword, char * newpassword) +BOOL smb_pam_passchange(const char * user, const char * oldpassword, const char * newpassword) { /* Appropriate quantities of root should be obtained BEFORE calling this function */ struct pam_conv *pconv = NULL; diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 671f18a7b0..c58afc1f89 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -52,17 +52,6 @@ BOOL initialize_password_db(BOOL reload) } -/************************************************************* - Initialises a struct sam_disp_info. - **************************************************************/ - -static void pdb_init_dispinfo(struct sam_disp_info *user) -{ - if (user == NULL) - return; - ZERO_STRUCTP(user); -} - /************************************************************ Fill the SAM_ACCOUNT with default values. @@ -253,26 +242,6 @@ BOOL pdb_free_sam(SAM_ACCOUNT **user) } -/************************************************************************* - Routine to return the next entry in the sam passwd list. - *************************************************************************/ - -struct sam_disp_info *pdb_sam_to_dispinfo(SAM_ACCOUNT *user) -{ - static struct sam_disp_info disp_info; - - if (user == NULL) - return NULL; - - pdb_init_dispinfo(&disp_info); - - disp_info.smb_name = user->username; - disp_info.full_name = user->full_name; - disp_info.user_rid = user->user_rid; - - return &disp_info; -} - /********************************************************** Encode the account control bits into a string. length = length of string to encode into (including terminating @@ -354,7 +323,7 @@ uint16 pdb_decode_acct_ctrl(const char *p) Routine to set 32 hex password characters from a 16 byte array. **************************************************************/ -void pdb_sethexpwd(char *p, unsigned char *pwd, uint16 acct_ctrl) +void pdb_sethexpwd(char *p, const unsigned char *pwd, uint16 acct_ctrl) { if (pwd != NULL) { int i; @@ -373,7 +342,7 @@ void pdb_sethexpwd(char *p, unsigned char *pwd, uint16 acct_ctrl) into a 16 byte array. **************************************************************/ -BOOL pdb_gethexpwd(char *p, unsigned char *pwd) +BOOL pdb_gethexpwd(const char *p, unsigned char *pwd) { int i; unsigned char lonybble, hinybble; @@ -405,9 +374,9 @@ BOOL pdb_gethexpwd(char *p, unsigned char *pwd) Group and User RID username mapping function ********************************************************************/ -BOOL pdb_name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid) +BOOL pdb_name_to_rid(const char *user_name, uint32 *u_rid, uint32 *g_rid) { - struct passwd *pw = Get_Pwnam(user_name, False); + struct passwd *pw = Get_Pwnam(user_name); if (u_rid == NULL || g_rid == NULL || user_name == NULL) return False; @@ -446,6 +415,15 @@ gid_t pdb_user_rid_to_gid(uint32 user_rid) } /******************************************************************* + Converts NT group RID to a UNIX gid. + ********************************************************************/ + +gid_t pdb_group_rid_to_gid(uint32 group_rid) +{ + return (gid_t)(((group_rid & (~GROUP_RID_TYPE))- 1000)/RID_MULTIPLIER); +} + +/******************************************************************* converts UNIX uid to an NT User RID. ********************************************************************/ @@ -628,7 +606,7 @@ BOOL local_lookup_name(const char *c_domain, const char *c_user, DOM_SID *psid, (void)map_username(user); - if((pass = Get_Pwnam(user, False))) { + if((pass = Get_Pwnam(user))) { sid_append_rid( &local_sid, pdb_uid_to_user_rid(pass->pw_uid)); *psid_name_use = SID_NAME_USER; } else { @@ -881,8 +859,8 @@ void copy_sam_passwd(SAM_ACCOUNT *to, const SAM_ACCOUNT *from) --jerry *************************************************************/ -BOOL local_password_change(char *user_name, int local_flags, - char *new_passwd, +BOOL local_password_change(const char *user_name, int local_flags, + const char *new_passwd, char *err_str, size_t err_str_len, char *msg_str, size_t msg_str_len) { @@ -1042,7 +1020,7 @@ account without a valid local system user.\n", user_name); Collection of get...() functions for SAM_ACCOUNT_INFO. ********************************************************************/ -uint16 pdb_get_acct_ctrl (SAM_ACCOUNT *sampass) +uint16 pdb_get_acct_ctrl (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->acct_ctrl); @@ -1050,7 +1028,7 @@ uint16 pdb_get_acct_ctrl (SAM_ACCOUNT *sampass) return (ACB_DISABLED); } -time_t pdb_get_logon_time (SAM_ACCOUNT *sampass) +time_t pdb_get_logon_time (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->logon_time); @@ -1058,7 +1036,7 @@ time_t pdb_get_logon_time (SAM_ACCOUNT *sampass) return (0); } -time_t pdb_get_logoff_time (SAM_ACCOUNT *sampass) +time_t pdb_get_logoff_time (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->logoff_time); @@ -1066,7 +1044,7 @@ time_t pdb_get_logoff_time (SAM_ACCOUNT *sampass) return (-1); } -time_t pdb_get_kickoff_time (SAM_ACCOUNT *sampass) +time_t pdb_get_kickoff_time (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->kickoff_time); @@ -1074,7 +1052,7 @@ time_t pdb_get_kickoff_time (SAM_ACCOUNT *sampass) return (-1); } -time_t pdb_get_pass_last_set_time (SAM_ACCOUNT *sampass) +time_t pdb_get_pass_last_set_time (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->pass_last_set_time); @@ -1082,7 +1060,7 @@ time_t pdb_get_pass_last_set_time (SAM_ACCOUNT *sampass) return (-1); } -time_t pdb_get_pass_can_change_time (SAM_ACCOUNT *sampass) +time_t pdb_get_pass_can_change_time (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->pass_can_change_time); @@ -1090,7 +1068,7 @@ time_t pdb_get_pass_can_change_time (SAM_ACCOUNT *sampass) return (-1); } -time_t pdb_get_pass_must_change_time (SAM_ACCOUNT *sampass) +time_t pdb_get_pass_must_change_time (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->pass_must_change_time); @@ -1098,7 +1076,7 @@ time_t pdb_get_pass_must_change_time (SAM_ACCOUNT *sampass) return (-1); } -uint16 pdb_get_logon_divs (SAM_ACCOUNT *sampass) +uint16 pdb_get_logon_divs (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->logon_divs); @@ -1106,7 +1084,7 @@ uint16 pdb_get_logon_divs (SAM_ACCOUNT *sampass) return (-1); } -uint32 pdb_get_hours_len (SAM_ACCOUNT *sampass) +uint32 pdb_get_hours_len (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->hours_len); @@ -1114,7 +1092,7 @@ uint32 pdb_get_hours_len (SAM_ACCOUNT *sampass) return (-1); } -uint8* pdb_get_hours (SAM_ACCOUNT *sampass) +const uint8* pdb_get_hours (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->hours); @@ -1122,7 +1100,7 @@ uint8* pdb_get_hours (SAM_ACCOUNT *sampass) return (NULL); } -uint8* pdb_get_nt_passwd (SAM_ACCOUNT *sampass) +const uint8* pdb_get_nt_passwd (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->nt_pw); @@ -1130,7 +1108,7 @@ uint8* pdb_get_nt_passwd (SAM_ACCOUNT *sampass) return (NULL); } -uint8* pdb_get_lanman_passwd (SAM_ACCOUNT *sampass) +const uint8* pdb_get_lanman_passwd (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->lm_pw); @@ -1138,7 +1116,7 @@ uint8* pdb_get_lanman_passwd (SAM_ACCOUNT *sampass) return (NULL); } -uint32 pdb_get_user_rid (SAM_ACCOUNT *sampass) +uint32 pdb_get_user_rid (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->user_rid); @@ -1146,7 +1124,7 @@ uint32 pdb_get_user_rid (SAM_ACCOUNT *sampass) return (-1); } -uint32 pdb_get_group_rid (SAM_ACCOUNT *sampass) +uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->group_rid); @@ -1154,7 +1132,7 @@ uint32 pdb_get_group_rid (SAM_ACCOUNT *sampass) return (-1); } -uid_t pdb_get_uid (SAM_ACCOUNT *sampass) +uid_t pdb_get_uid (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->uid); @@ -1162,7 +1140,7 @@ uid_t pdb_get_uid (SAM_ACCOUNT *sampass) return ((uid_t)-1); } -gid_t pdb_get_gid (SAM_ACCOUNT *sampass) +gid_t pdb_get_gid (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->gid); @@ -1170,7 +1148,7 @@ gid_t pdb_get_gid (SAM_ACCOUNT *sampass) return ((gid_t)-1); } -char* pdb_get_username (SAM_ACCOUNT *sampass) +const char* pdb_get_username (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->username); @@ -1178,7 +1156,7 @@ char* pdb_get_username (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_domain (SAM_ACCOUNT *sampass) +const char* pdb_get_domain (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->domain); @@ -1186,7 +1164,7 @@ char* pdb_get_domain (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_nt_username (SAM_ACCOUNT *sampass) +const char* pdb_get_nt_username (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->nt_username); @@ -1194,7 +1172,7 @@ char* pdb_get_nt_username (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_fullname (SAM_ACCOUNT *sampass) +const char* pdb_get_fullname (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->full_name); @@ -1202,7 +1180,7 @@ char* pdb_get_fullname (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_homedir (SAM_ACCOUNT *sampass) +const char* pdb_get_homedir (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->home_dir); @@ -1210,7 +1188,7 @@ char* pdb_get_homedir (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_dirdrive (SAM_ACCOUNT *sampass) +const char* pdb_get_dirdrive (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->dir_drive); @@ -1218,7 +1196,7 @@ char* pdb_get_dirdrive (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_logon_script (SAM_ACCOUNT *sampass) +const char* pdb_get_logon_script (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->logon_script); @@ -1226,7 +1204,7 @@ char* pdb_get_logon_script (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_profile_path (SAM_ACCOUNT *sampass) +const char* pdb_get_profile_path (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->profile_path); @@ -1234,7 +1212,7 @@ char* pdb_get_profile_path (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_acct_desc (SAM_ACCOUNT *sampass) +const char* pdb_get_acct_desc (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->acct_desc); @@ -1242,7 +1220,7 @@ char* pdb_get_acct_desc (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_workstations (SAM_ACCOUNT *sampass) +const char* pdb_get_workstations (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->workstations); @@ -1250,7 +1228,7 @@ char* pdb_get_workstations (SAM_ACCOUNT *sampass) return (NULL); } -char* pdb_get_munged_dial (SAM_ACCOUNT *sampass) +const char* pdb_get_munged_dial (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->munged_dial); @@ -1258,7 +1236,7 @@ char* pdb_get_munged_dial (SAM_ACCOUNT *sampass) return (NULL); } -uint32 pdb_get_unknown3 (SAM_ACCOUNT *sampass) +uint32 pdb_get_unknown3 (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->unknown_3); @@ -1266,7 +1244,7 @@ uint32 pdb_get_unknown3 (SAM_ACCOUNT *sampass) return (-1); } -uint32 pdb_get_unknown5 (SAM_ACCOUNT *sampass) +uint32 pdb_get_unknown5 (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->unknown_5); @@ -1274,7 +1252,7 @@ uint32 pdb_get_unknown5 (SAM_ACCOUNT *sampass) return (-1); } -uint32 pdb_get_unknown6 (SAM_ACCOUNT *sampass) +uint32 pdb_get_unknown6 (const SAM_ACCOUNT *sampass) { if (sampass) return (sampass->unknown_6); @@ -1411,7 +1389,7 @@ BOOL pdb_set_group_rid (SAM_ACCOUNT *sampass, uint32 grid) Set the user's UNIX name. ********************************************************************/ -BOOL pdb_set_username(SAM_ACCOUNT *sampass, char *username) +BOOL pdb_set_username(SAM_ACCOUNT *sampass, const char *username) { if (!sampass) return False; @@ -1428,7 +1406,7 @@ BOOL pdb_set_username(SAM_ACCOUNT *sampass, char *username) Set the domain name. ********************************************************************/ -BOOL pdb_set_domain(SAM_ACCOUNT *sampass, char *domain) +BOOL pdb_set_domain(SAM_ACCOUNT *sampass, const char *domain) { if (!sampass) return False; @@ -1445,7 +1423,7 @@ BOOL pdb_set_domain(SAM_ACCOUNT *sampass, char *domain) Set the user's NT name. ********************************************************************/ -BOOL pdb_set_nt_username(SAM_ACCOUNT *sampass, char *nt_username) +BOOL pdb_set_nt_username(SAM_ACCOUNT *sampass, const char *nt_username) { if (!sampass) return False; @@ -1462,7 +1440,7 @@ BOOL pdb_set_nt_username(SAM_ACCOUNT *sampass, char *nt_username) Set the user's full name. ********************************************************************/ -BOOL pdb_set_fullname(SAM_ACCOUNT *sampass, char *fullname) +BOOL pdb_set_fullname(SAM_ACCOUNT *sampass, const char *fullname) { if (!sampass) return False; @@ -1479,7 +1457,7 @@ BOOL pdb_set_fullname(SAM_ACCOUNT *sampass, char *fullname) Set the user's logon script. ********************************************************************/ -BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, char *logon_script) +BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, const char *logon_script) { if (!sampass) return False; @@ -1496,7 +1474,7 @@ BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, char *logon_script) Set the user's profile path. ********************************************************************/ -BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, char *profile_path) +BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, const char *profile_path) { if (!sampass) return False; @@ -1513,7 +1491,7 @@ BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, char *profile_path) Set the user's directory drive. ********************************************************************/ -BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, char *dir_drive) +BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, const char *dir_drive) { if (!sampass) return False; @@ -1530,7 +1508,7 @@ BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, char *dir_drive) Set the user's home directory. ********************************************************************/ -BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, char *homedir) +BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, const char *homedir) { if (!sampass) return False; @@ -1547,7 +1525,7 @@ BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, char *homedir) Set the user's account description. ********************************************************************/ -BOOL pdb_set_acct_desc (SAM_ACCOUNT *sampass, char *acct_desc) +BOOL pdb_set_acct_desc (SAM_ACCOUNT *sampass, const char *acct_desc) { if (!sampass) return False; @@ -1564,7 +1542,7 @@ BOOL pdb_set_acct_desc (SAM_ACCOUNT *sampass, char *acct_desc) Set the user's workstation allowed list. ********************************************************************/ -BOOL pdb_set_workstations (SAM_ACCOUNT *sampass, char *workstations) +BOOL pdb_set_workstations (SAM_ACCOUNT *sampass, const char *workstations) { if (!sampass) return False; @@ -1581,7 +1559,7 @@ BOOL pdb_set_workstations (SAM_ACCOUNT *sampass, char *workstations) Set the user's dial string. ********************************************************************/ -BOOL pdb_set_munged_dial (SAM_ACCOUNT *sampass, char *munged_dial) +BOOL pdb_set_munged_dial (SAM_ACCOUNT *sampass, const char *munged_dial) { if (!sampass) return False; @@ -1598,7 +1576,7 @@ BOOL pdb_set_munged_dial (SAM_ACCOUNT *sampass, char *munged_dial) Set the user's NT hash. ********************************************************************/ -BOOL pdb_set_nt_passwd (SAM_ACCOUNT *sampass, uint8 *pwd) +BOOL pdb_set_nt_passwd (SAM_ACCOUNT *sampass, const uint8 *pwd) { if (!sampass) return False; @@ -1626,7 +1604,7 @@ BOOL pdb_set_nt_passwd (SAM_ACCOUNT *sampass, uint8 *pwd) Set the user's LM hash. ********************************************************************/ -BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, uint8 *pwd) +BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, const uint8 *pwd) { if (!sampass) return False; @@ -1677,7 +1655,7 @@ BOOL pdb_set_unknown_6 (SAM_ACCOUNT *sampass, uint32 unkn) return True; } -BOOL pdb_set_hours (SAM_ACCOUNT *sampass, uint8 *hours) +BOOL pdb_set_hours (SAM_ACCOUNT *sampass, const uint8 *hours) { if (!sampass) return False; diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index d44a6133f3..057395a381 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -264,7 +264,7 @@ Routine to manage the LDAPMod structure array manage memory used by the array, by each struct, and values ************************************************************************/ -static void make_a_mod (LDAPMod *** modlist, int modop, char *attribute, char *value) +static void make_a_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value) { LDAPMod **mods; int i; @@ -522,7 +522,7 @@ static BOOL init_sam_from_ldap (SAM_ACCOUNT * sampass, Initialize SAM_ACCOUNT from an LDAP query (Based on init_buffer_from_sam in pdb_tdb.c) *********************************************************************/ -static BOOL init_ldap_from_sam (LDAPMod *** mods, int ldap_state, SAM_ACCOUNT * sampass) +static BOOL init_ldap_from_sam (LDAPMod *** mods, int ldap_state, const SAM_ACCOUNT * sampass) { pstring temp; @@ -676,7 +676,7 @@ BOOL pdb_getsampwent(SAM_ACCOUNT * user) /********************************************************************** Get SAM_ACCOUNT entry from LDAP by username *********************************************************************/ -BOOL pdb_getsampwnam(SAM_ACCOUNT * user, char *sname) +BOOL pdb_getsampwnam(SAM_ACCOUNT * user, const char *sname) { LDAP *ldap_struct; LDAPMessage *result; @@ -820,7 +820,7 @@ BOOL pdb_getsampwuid(SAM_ACCOUNT * user, uid_t uid) /********************************************************************** Delete entry from LDAP for username *********************************************************************/ -BOOL pdb_delete_sam_account(char *sname) +BOOL pdb_delete_sam_account(const char *sname) { int rc; char *dn; @@ -871,7 +871,7 @@ BOOL pdb_delete_sam_account(char *sname) /********************************************************************** Update SAM_ACCOUNT *********************************************************************/ -BOOL pdb_update_sam_account(SAM_ACCOUNT * newpwd, BOOL override) +BOOL pdb_update_sam_account(const SAM_ACCOUNT * newpwd, BOOL override) { int rc; char *dn; @@ -932,7 +932,7 @@ BOOL pdb_update_sam_account(SAM_ACCOUNT * newpwd, BOOL override) /********************************************************************** Add SAM_ACCOUNT to LDAP *********************************************************************/ -BOOL pdb_add_sam_account(SAM_ACCOUNT * newpwd) +BOOL pdb_add_sam_account(const SAM_ACCOUNT * newpwd) { int rc; pstring filter; diff --git a/source3/passdb/pdb_nisplus.c b/source3/passdb/pdb_nisplus.c index a86d5ecb68..dddab8bdee 100644 --- a/source3/passdb/pdb_nisplus.c +++ b/source3/passdb/pdb_nisplus.c @@ -156,7 +156,7 @@ static char *make_nisname_from_uid(int uid, char *pfile) /*************************************************************** make_nisname_from_name ****************************************************************/ -static char *make_nisname_from_name(char *user_name, char *pfile) +static char *make_nisname_from_name(const char *user_name, char *pfile) { static pstring nisname; @@ -171,7 +171,7 @@ static char *make_nisname_from_name(char *user_name, char *pfile) /************************************************************************* gets a NIS+ attribute *************************************************************************/ -static void get_single_attribute(nis_object *new_obj, int col, +static void get_single_attribute(const nis_object *new_obj, int col, char *val, int len) { int entry_len; @@ -190,7 +190,7 @@ static void get_single_attribute(nis_object *new_obj, int col, /************************************************************************ makes a struct sam_passwd from a NIS+ object. ************************************************************************/ -static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, nis_object *obj) +static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, const nis_object *obj) { char *ptr; pstring full_name; /* this must be translated to dos code page */ @@ -405,7 +405,7 @@ static BOOL make_sam_from_nisp_object(SAM_ACCOUNT *pw_buf, nis_object *obj) /************************************************************************ makes a struct sam_passwd from a NIS+ result. ************************************************************************/ -static BOOL make_sam_from_nisresult(SAM_ACCOUNT *pw_buf, nis_result *result) +static BOOL make_sam_from_nisresult(SAM_ACCOUNT *pw_buf, const nis_result *result) { if (pw_buf == NULL || result == NULL) return False; @@ -436,7 +436,7 @@ static BOOL make_sam_from_nisresult(SAM_ACCOUNT *pw_buf, nis_result *result) sets a NIS+ attribute *************************************************************************/ static void set_single_attribute(nis_object *new_obj, int col, - char *val, int len, int flags) + const char *val, int len, int flags) { if (new_obj == NULL) return; @@ -453,7 +453,7 @@ static void set_single_attribute(nis_object *new_obj, int col, copy or modify nis object. this object is used to add or update nisplus table entry. ****************************************************************/ -static BOOL init_nisp_from_sam(nis_object *obj, SAM_ACCOUNT *sampass, +static BOOL init_nisp_from_sam(nis_object *obj, const SAM_ACCOUNT *sampass, nis_object *old) { /* @@ -470,7 +470,7 @@ static BOOL init_nisp_from_sam(nis_object *obj, SAM_ACCOUNT *sampass, * store */ BOOL need_to_modify = False; - char *name; /* from SAM */ + const char *name = pdb_get_username(sampass); /* from SAM */ /* these must be static or allocate and free entry columns! */ static fstring uid; /* from SAM */ static fstring user_rid; /* from SAM */ @@ -489,8 +489,6 @@ static BOOL init_nisp_from_sam(nis_object *obj, SAM_ACCOUNT *sampass, static fstring acct_desc; /* from SAM */ static char empty[1]; /* just an empty string */ - - name = pdb_get_username(sampass); slprintf(uid, sizeof(uid)-1, "%u", pdb_get_uid(sampass)); slprintf(user_rid, sizeof(user_rid)-1, "%u", pdb_get_user_rid(sampass)? pdb_get_user_rid(sampass): @@ -768,7 +766,7 @@ static BOOL init_nisp_from_sam(nis_object *obj, SAM_ACCOUNT *sampass, pdb_get_hours_len(sampass)-1, EN_MODIFIED); } } else { - char *homedir, *dirdrive, *logon_script, *profile_path, *workstations; + const char *homedir, *dirdrive, *logon_script, *profile_path, *workstations; *empty = '\0'; /* empty string */ @@ -844,7 +842,7 @@ static BOOL init_nisp_from_sam(nis_object *obj, SAM_ACCOUNT *sampass, /*************************************************************** calls nis_list, returns results. ****************************************************************/ -static nis_result *nisp_get_nis_list(char *nis_name, uint_t flags) +static nis_result *nisp_get_nis_list(const char *nis_name, uint_t flags) { nis_result *result; int i; @@ -940,7 +938,7 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user) /************************************************************************* Routine to search the nisplus passwd file for an entry matching the username *************************************************************************/ -BOOL pdb_getsampwnam(SAM_ACCOUNT * user, char *sname) +BOOL pdb_getsampwnam(SAM_ACCOUNT * user, const char *sname) { /* Static buffers we will return. */ nis_result *result = NULL; @@ -1056,7 +1054,7 @@ BOOL pdb_getsampwuid(SAM_ACCOUNT * user, uid_t uid) /************************************************************************* Routine to remove entry from the nisplus smbpasswd table *************************************************************************/ -BOOL pdb_delete_sam_account(char *sname) +BOOL pdb_delete_sam_account(const char *sname) { char *pfile = lp_smb_passwd_file(); pstring nisname; @@ -1112,7 +1110,7 @@ BOOL pdb_delete_sam_account(char *sname) /************************************************************************ Routine to add an entry to the nisplus passwd file. *************************************************************************/ -BOOL pdb_add_sam_account(SAM_ACCOUNT * newpwd) +BOOL pdb_add_sam_account(const SAM_ACCOUNT * newpwd) { int local_user = 0; char *pfile; @@ -1307,7 +1305,7 @@ BOOL pdb_add_sam_account(SAM_ACCOUNT * newpwd) /************************************************************************ Routine to modify the nisplus passwd entry. ************************************************************************/ -BOOL pdb_update_sam_account(SAM_ACCOUNT * newpwd, BOOL override) +BOOL pdb_update_sam_account(const SAM_ACCOUNT * newpwd, BOOL override) { nis_result *result, *addresult; nis_object *obj; diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index 85e91bc5ba..8524275f12 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -34,10 +34,10 @@ struct smb_passwd { uid_t smb_userid; /* this is actually the unix uid_t */ - char *smb_name; /* username string */ + const char *smb_name; /* username string */ - unsigned char *smb_passwd; /* Null if no password */ - unsigned char *smb_nt_passwd; /* Null if no password */ + const unsigned char *smb_passwd; /* Null if no password */ + const unsigned char *smb_nt_passwd; /* Null if no password */ uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */ time_t pass_last_set_time; /* password last set time */ @@ -489,7 +489,7 @@ static struct smb_passwd *getsmbfilepwent(void *vp) Create a new smbpasswd entry - malloced space returned. *************************************************************************/ -static char *format_new_smbpasswd_entry(struct smb_passwd *newpwd) +static char *format_new_smbpasswd_entry(const struct smb_passwd *newpwd) { int new_entry_length; char *new_entry; @@ -549,7 +549,7 @@ static char *format_new_smbpasswd_entry(struct smb_passwd *newpwd) Routine to add an entry to the smbpasswd file. *************************************************************************/ -static BOOL add_smbfilepwd_entry(struct smb_passwd *newpwd) +static BOOL add_smbfilepwd_entry(const struct smb_passwd *newpwd) { char *pfile = lp_smb_passwd_file(); struct smb_passwd *pwd = NULL; @@ -651,7 +651,7 @@ Error was %s. Password file may be corrupt ! Please examine by hand !\n", override = True, override XXXXXXXX'd out password or NO PASS ************************************************************************/ -static BOOL mod_smbfilepwd_entry(struct smb_passwd* pwd, BOOL override) +static BOOL mod_smbfilepwd_entry(const struct smb_passwd* pwd, BOOL override) { /* Static buffers we will return. */ static pstring user_name; @@ -1323,7 +1323,7 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user) call getpwnam() for unix account information until we have found the correct entry ***************************************************************/ -BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, char *username) +BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username) { struct smb_passwd *smb_pw; void *fp = NULL; @@ -1508,7 +1508,7 @@ BOOL pdb_update_sam_account(const SAM_ACCOUNT *sampass, BOOL override) return True; } -BOOL pdb_delete_sam_account (char* username) +BOOL pdb_delete_sam_account (const char* username) { return del_smbfilepwd_entry(username); } diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index 95f66fc671..a170ac1345 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -173,7 +173,7 @@ done: /********************************************************************** Intialize a BYTE buffer from a SAM_ACCOUNT struct *********************************************************************/ -static uint32 init_buffer_from_sam (uint8 **buf, SAM_ACCOUNT *sampass) +static uint32 init_buffer_from_sam (uint8 **buf, const SAM_ACCOUNT *sampass) { size_t len, buflen; @@ -186,25 +186,25 @@ static uint32 init_buffer_from_sam (uint8 **buf, SAM_ACCOUNT *sampass) pass_last_set_time, pass_can_change_time, pass_must_change_time; - char *username; - char *domain; - char *nt_username; - char *dir_drive; - char *unknown_str; - char *munged_dial; - char *fullname; - char *homedir; - char *logon_script; - char *profile_path; - char *acct_desc; - char *workstations; + const char *username; + const char *domain; + const char *nt_username; + const char *dir_drive; + const char *unknown_str; + const char *munged_dial; + const char *fullname; + const char *homedir; + const char *logon_script; + const char *profile_path; + const char *acct_desc; + const char *workstations; uint32 username_len, domain_len, nt_username_len, dir_drive_len, unknown_str_len, munged_dial_len, fullname_len, homedir_len, logon_script_len, profile_path_len, acct_desc_len, workstations_len; - uint8 *lm_pw; - uint8 *nt_pw; + const uint8 *lm_pw; + const uint8 *nt_pw; uint32 lm_pw_len = 16; uint32 nt_pw_len = 16; @@ -476,7 +476,7 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user) Lookup a name in the SAM TDB ******************************************************************/ -BOOL pdb_getsampwnam (SAM_ACCOUNT *user, char *sname) +BOOL pdb_getsampwnam (SAM_ACCOUNT *user, const char *sname) { TDB_CONTEXT *pwd_tdb; TDB_DATA data, key; @@ -624,7 +624,7 @@ BOOL pdb_getsampwrid (SAM_ACCOUNT *user, uint32 rid) Delete a SAM_ACCOUNT ****************************************************************************/ -BOOL pdb_delete_sam_account(char *sname) +BOOL pdb_delete_sam_account(const char *sname) { SAM_ACCOUNT *sam_pass = NULL; TDB_CONTEXT *pwd_tdb; @@ -799,7 +799,7 @@ done: Modifies an existing SAM_ACCOUNT ****************************************************************************/ -BOOL pdb_update_sam_account (SAM_ACCOUNT *newpwd, BOOL override) +BOOL pdb_update_sam_account (const SAM_ACCOUNT *newpwd, BOOL override) { return (tdb_update_sam(newpwd, override, TDB_MODIFY)); } @@ -808,7 +808,7 @@ BOOL pdb_update_sam_account (SAM_ACCOUNT *newpwd, BOOL override) Adds an existing SAM_ACCOUNT ****************************************************************************/ -BOOL pdb_add_sam_account (SAM_ACCOUNT *newpwd) +BOOL pdb_add_sam_account (const SAM_ACCOUNT *newpwd) { return (tdb_update_sam(newpwd, True, TDB_INSERT)); } |