return vuser->vuid;
}
+static int register_homes_share(const char *username)
+{
+ int result;
+ struct passwd *pwd;
+
+ result = lp_servicenumber(username);
+ if (result != -1) {
+ DEBUG(3, ("Using static (or previously created) service for "
+ "user '%s'; path = '%s'\n", username,
+ lp_pathname(result)));
+ return result;
+ }
+
+ pwd = getpwnam_alloc(talloc_tos(), username);
+
+ if ((pwd == NULL) || (pwd->pw_dir[0] == '\0')) {
+ DEBUG(3, ("No home directory defined for user '%s'\n",
+ username));
+ TALLOC_FREE(pwd);
+ return -1;
+ }
+
+ DEBUG(3, ("Adding homes service for user '%s' using home directory: "
+ "'%s'\n", username, pwd->pw_dir));
+
+ result = add_home_service(username, username, pwd->pw_dir);
+
+ TALLOC_FREE(pwd);
+ return result;
+}
+
/**
* register that a valid login has been performed, establish 'session'.
* @param server_info The token returned from the authentication process.
talloc_steal(vuser, vuser->server_info);
- /* the next functions should be done by a SID mapping system (SMS) as
- * the new real sam db won't have reference to unix uids or gids
- */
-
- vuser->uid = server_info->uid;
- vuser->gid = server_info->gid;
-
- vuser->n_groups = server_info->n_groups;
- if (vuser->n_groups) {
- if (!(vuser->groups = (gid_t *)talloc_memdup(vuser,
- server_info->groups,
- sizeof(gid_t)*vuser->n_groups))) {
- DEBUG(0,("register_existing_vuid: "
- "failed to talloc_memdup vuser->groups\n"));
- goto fail;
- }
- }
-
vuser->guest = server_info->guest;
fstrcpy(vuser->user.unix_name, server_info->unix_name);
fstrcpy(vuser->user.full_name,
pdb_get_fullname(server_info->sam_account));
- {
- /* Keep the homedir handy */
- const char *homedir =
- pdb_get_homedir(server_info->sam_account);
- const char *logon_script =
- pdb_get_logon_script(server_info->sam_account);
-
- if (!IS_SAM_DEFAULT(server_info->sam_account,
- PDB_UNIXHOMEDIR)) {
- const char *unix_homedir =
- pdb_get_unix_homedir(server_info->sam_account);
- if (unix_homedir) {
- vuser->unix_homedir = unix_homedir;
- }
- } else {
- struct passwd *passwd =
- getpwnam_alloc(vuser, vuser->user.unix_name);
- if (passwd) {
- vuser->unix_homedir = passwd->pw_dir;
- /* Ensure that the unix_homedir now
- * belongs to vuser, so it goes away
- * with it, not with passwd below: */
- talloc_steal(vuser, vuser->unix_homedir);
- TALLOC_FREE(passwd);
- }
- }
-
- if (homedir) {
- vuser->homedir = homedir;
- }
- if (logon_script) {
- vuser->logon_script = logon_script;
- }
- }
vuser->session_key = session_key;
DEBUG(10,("register_existing_vuid: (%u,%u) %s %s %s guest=%d\n",
- (unsigned int)vuser->uid,
- (unsigned int)vuser->gid,
+ (unsigned int)vuser->server_info->uid,
+ (unsigned int)vuser->server_info->gid,
vuser->user.unix_name, vuser->user.smb_name,
vuser->user.domain, vuser->guest ));
"Real name: %s\n", vuser->user.unix_name,
vuser->user.full_name));
- if (server_info->ptok) {
- vuser->nt_user_token = dup_nt_token(vuser, server_info->ptok);
- } else {
+ if (!server_info->ptok) {
DEBUG(1, ("register_existing_vuid: server_info does not "
"contain a user_token - cannot continue\n"));
goto fail;
}
DEBUG(3,("register_existing_vuid: UNIX uid %d is UNIX user %s, "
- "and will be vuid %u\n",
- (int)vuser->uid,vuser->user.unix_name, vuser->vuid));
+ "and will be vuid %u\n", (int)vuser->server_info->uid,
+ vuser->user.unix_name, vuser->vuid));
next_vuid++;
num_validated_vuids++;
If a share exists by this name (autoloaded or not) reuse it . */
vuser->homes_snum = -1;
- if ( (!vuser->guest) && vuser->unix_homedir && *(vuser->unix_homedir)) {
- int servicenumber = lp_servicenumber(vuser->user.unix_name);
- if ( servicenumber == -1 ) {
- DEBUG(3, ("Adding homes service for user '%s' using "
- "home directory: '%s'\n",
- vuser->user.unix_name, vuser->unix_homedir));
- vuser->homes_snum =
- add_home_service(vuser->user.unix_name,
- vuser->user.unix_name,
- vuser->unix_homedir);
- } else {
- DEBUG(3, ("Using static (or previously created) "
- "service for user '%s'; path = '%s'\n",
- vuser->user.unix_name,
- lp_pathname(servicenumber) ));
- vuser->homes_snum = servicenumber;
- }
+
+ if (!vuser->guest) {
+ vuser->homes_snum = register_homes_share(
+ vuser->user.unix_name);
}
if (srv_is_signing_negotiated() && !vuser->guest &&