summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-09-11 16:52:10 +0000
committerGerald Carter <jerry@samba.org>2003-09-11 16:52:10 +0000
commit1d0329c7686f3b657756c33b36c8cf797d01dced (patch)
tree9c789ffd1eb3ba3045daf43a827afecf6a51b09b
parent5cf58a1b982ba48521942842dd21cca2ca02f4d0 (diff)
downloadsamba-1d0329c7686f3b657756c33b36c8cf797d01dced.tar.gz
samba-1d0329c7686f3b657756c33b36c8cf797d01dced.tar.bz2
samba-1d0329c7686f3b657756c33b36c8cf797d01dced.zip
remove getpwnam() calls from init_sam_from_xxx().
This means that %u & %g will no longer expand, but %U and %G still do. The payback is that winbindd local accounts for users work with 'wbinfo -u' when winbind is running on a PDC. (This used to be commit eb02fcf3c212eee1dc267959f23da5a26c1eac4f)
-rw-r--r--source3/passdb/passdb.c37
-rw-r--r--source3/passdb/pdb_ldap.c54
2 files changed, 30 insertions, 61 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 76745be3f0..1dadee8a49 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -1311,9 +1311,6 @@ BOOL init_sam_from_buffer(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
uint32 len = 0;
uint32 lm_pw_len, nt_pw_len, hourslen;
BOOL ret = True;
- uid_t uid = -1;
- gid_t gid = -1;
- struct passwd *pw = NULL;
if(sampass == NULL || buf == NULL) {
DEBUG(0, ("init_sam_from_buffer: NULL parameters found!\n"));
@@ -1369,55 +1366,37 @@ BOOL init_sam_from_buffer(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_nt_username(sampass, nt_username, PDB_SET);
pdb_set_fullname(sampass, fullname, PDB_SET);
-
- if ( (pw=Get_Pwnam(username)) != NULL ) {
- uid = pw->pw_uid;
- gid = pw->pw_gid;
- }
-
if (homedir) {
pdb_set_homedir(sampass, homedir, PDB_SET);
}
else {
pdb_set_homedir(sampass,
- talloc_sub_specified(sampass->mem_ctx,
- lp_logon_home(),
- username, domain,
- uid, gid),
- PDB_DEFAULT);
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
+ PDB_DEFAULT);
}
if (dir_drive)
pdb_set_dir_drive(sampass, dir_drive, PDB_SET);
else {
pdb_set_dir_drive(sampass,
- talloc_sub_specified(sampass->mem_ctx,
- lp_logon_drive(),
- username, domain,
- uid, gid),
- PDB_DEFAULT);
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_drive()),
+ PDB_DEFAULT);
}
if (logon_script)
pdb_set_logon_script(sampass, logon_script, PDB_SET);
else {
pdb_set_logon_script(sampass,
- talloc_sub_specified(sampass->mem_ctx,
- lp_logon_script(),
- username, domain,
- uid, gid),
- PDB_DEFAULT);
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
+ PDB_DEFAULT);
}
if (profile_path) {
pdb_set_profile_path(sampass, profile_path, PDB_SET);
} else {
pdb_set_profile_path(sampass,
- talloc_sub_specified(sampass->mem_ctx,
- lp_logon_path(),
- username, domain,
- uid, gid),
- PDB_DEFAULT);
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_path()),
+ PDB_DEFAULT);
}
pdb_set_acct_desc(sampass, acct_desc, PDB_SET);
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index b1cc35e4f2..e00631fb7d 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -425,9 +425,6 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
uint32 hours_len;
uint8 hours[MAX_HOURS_LEN];
pstring temp;
- struct passwd *pw = NULL;
- uid_t uid = -1;
- gid_t gid = -1;
/*
* do a little initialization
@@ -462,14 +459,6 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
DEBUG(2, ("init_sam_from_ldap: Entry found for user: %s\n", username));
- /* I'm not going to fail here, since there are checks
- higher up the cal stack to do this --jerry */
-
- if ( (pw=Get_Pwnam(username)) != NULL ) {
- uid = pw->pw_uid;
- gid = pw->pw_gid;
- }
-
pstrcpy(nt_username, username);
pstrcpy(domain, ldap_state->domain_name);
@@ -615,47 +604,48 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
}
if (!smbldap_get_single_attribute(ldap_state->smbldap_state->ldap_struct, entry,
- get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_HOME_DRIVE), dir_drive)) {
- pdb_set_dir_drive(sampass, talloc_sub_specified(sampass->mem_ctx,
- lp_logon_drive(),
- username, domain,
- uid, gid), PDB_DEFAULT);
+ get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_HOME_DRIVE), dir_drive))
+ {
+ pdb_set_dir_drive( sampass,
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_drive()),
+ PDB_DEFAULT );
} else {
pdb_set_dir_drive(sampass, dir_drive, PDB_SET);
}
if (!smbldap_get_single_attribute(ldap_state->smbldap_state->ldap_struct, entry,
- get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_HOME_PATH), homedir)) {
- pdb_set_homedir(sampass, talloc_sub_specified(sampass->mem_ctx,
- lp_logon_home(),
- username, domain,
- uid, gid), PDB_DEFAULT);
+ get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_HOME_PATH), homedir))
+ {
+ pdb_set_homedir( sampass,
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
+ PDB_DEFAULT );
} else {
pdb_set_homedir(sampass, homedir, PDB_SET);
}
if (!smbldap_get_single_attribute(ldap_state->smbldap_state->ldap_struct, entry,
- get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_LOGON_SCRIPT), logon_script)) {
- pdb_set_logon_script(sampass, talloc_sub_specified(sampass->mem_ctx,
- lp_logon_script(),
- username, domain,
- uid, gid), PDB_DEFAULT);
+ get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_LOGON_SCRIPT), logon_script))
+ {
+ pdb_set_logon_script( sampass,
+ talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
+ PDB_DEFAULT );
} else {
pdb_set_logon_script(sampass, logon_script, PDB_SET);
}
if (!smbldap_get_single_attribute(ldap_state->smbldap_state->ldap_struct, entry,
- get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_PROFILE_PATH), profile_path)) {
- pdb_set_profile_path(sampass, talloc_sub_specified(sampass->mem_ctx,
- lp_logon_path(),
- username, domain,
- uid, gid), PDB_DEFAULT);
+ get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_PROFILE_PATH), profile_path))
+ {
+ pdb_set_profile_path( sampass,
+ talloc_sub_basic( sampass->mem_ctx, username, lp_logon_path()),
+ PDB_DEFAULT );
} else {
pdb_set_profile_path(sampass, profile_path, PDB_SET);
}
if (!smbldap_get_single_attribute(ldap_state->smbldap_state->ldap_struct, entry,
- get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_DESC), acct_desc)) {
+ get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_DESC), acct_desc))
+ {
/* leave as default */
} else {
pdb_set_acct_desc(sampass, acct_desc, PDB_SET);