summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-03-26 21:52:12 +0000
committerJeremy Allison <jra@samba.org>2001-03-26 21:52:12 +0000
commitad02e0a799e139a58a7e5d1f05e144e485671847 (patch)
tree814f48886b361c8a6fe7f4a211d6ca74934a9346
parente7be5e5ea736e92f6e59bc53a58d08dec4307dfa (diff)
downloadsamba-ad02e0a799e139a58a7e5d1f05e144e485671847.tar.gz
samba-ad02e0a799e139a58a7e5d1f05e144e485671847.tar.xz
samba-ad02e0a799e139a58a7e5d1f05e144e485671847.zip
Patch to make automount lookup fallback to get home directory from getpwnam.
From Robert Montjoy <Rob_Montjoy@ECECS.UC.EDU>. Jeremy.
-rw-r--r--source/lib/substitute.c24
-rw-r--r--source/lib/util.c44
2 files changed, 40 insertions, 28 deletions
diff --git a/source/lib/substitute.c b/source/lib/substitute.c
index 09a60cf3f1e..c4bd1377c28 100644
--- a/source/lib/substitute.c
+++ b/source/lib/substitute.c
@@ -102,16 +102,22 @@ static char *automount_path(char *user_name)
#if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
- if (lp_nis_home_map())
- {
- char *home_path_start;
+ if (lp_nis_home_map()) {
+ char *home_path_start;
char *automount_value = automount_lookup(user_name);
- home_path_start = strchr(automount_value,':');
- if (home_path_start != NULL)
- {
- DEBUG(5, ("NIS lookup succeeded. Home path is: %s\n",
- home_path_start?(home_path_start+1):""));
- pstrcpy(server_path, home_path_start+1);
+
+ if(strlen(automount_value) > 0) {
+ home_path_start = strchr(automount_value,':');
+ if (home_path_start != NULL) {
+ DEBUG(5, ("NIS lookup succeeded. Home path is: %s\n",
+ home_path_start?(home_path_start+1):""));
+ pstrcpy(server_path, home_path_start+1);
+ }
+ } else {
+ /* NIS key lookup failed: default to user home directory from password file */
+ pstrcpy(server_path, get_user_home_dir(user_name));
+ DEBUG(5, ("NIS lookup failed. Using Home path from passwd file. Home path is: %s\n",
+ server_path ));
}
}
#endif
diff --git a/source/lib/util.c b/source/lib/util.c
index e7ad55fc9ef..09c47a0bba4 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -914,39 +914,45 @@ static char *automount_lookup(char *user_name)
char *nis_domain; /* yp_get_default_domain inits this */
char *nis_map = (char *)lp_nis_home_map_name();
- if ((nis_error = yp_get_default_domain(&nis_domain)) != 0)
- {
+ if ((nis_error = yp_get_default_domain(&nis_domain)) != 0) {
DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
return last_value;
}
DEBUG(5, ("NIS Domain: %s\n", nis_domain));
- if (!strcmp(user_name, last_key))
- {
- nis_result = last_value;
+ if (!strcmp(user_name, last_key)) {
+ nis_result = last_value;
nis_result_len = strlen(last_value);
nis_error = 0;
- }
- else
- {
+
+ } else {
+
if ((nis_error = yp_match(nis_domain, nis_map,
user_name, strlen(user_name),
- &nis_result, &nis_result_len)) != 0)
- {
- DEBUG(3, ("YP Error: \"%s\" while looking up \"%s\" in map \"%s\"\n",
+ &nis_result, &nis_result_len)) == 0) {
+ if (!nis_error && nis_result_len >= sizeof(pstring)) {
+ nis_result_len = sizeof(pstring)-1;
+ }
+ fstrcpy(last_key, user_name);
+ strncpy(last_value, nis_result, nis_result_len);
+ last_value[nis_result_len] = '\0';
+ strip_mount_options(&last_value);
+
+ } else if(nis_error == YPERR_KEY) {
+
+ /* If Key lookup fails user home server is not in nis_map
+ use default information for server, and home directory */
+ last_value[0] = 0;
+ DEBUG(3, ("YP Key not found: while looking up \"%s\" in map \"%s\"\n",
+ user_name, nis_map));
+ DEBUG(3, ("using defaults for server and home directory\n"));
+ } else {
+ DEBUG(3, ("YP Error: \"%s\" while looking up \"%s\" in map \"%s\"\n",
yperr_string(nis_error), user_name, nis_map));
}
- if (!nis_error && nis_result_len >= sizeof(pstring))
- {
- nis_result_len = sizeof(pstring)-1;
- }
- fstrcpy(last_key, user_name);
- strncpy(last_value, nis_result, nis_result_len);
- last_value[nis_result_len] = '\0';
}
- strip_mount_options(&last_value);
DEBUG(4, ("YP Lookup: %s resulted in %s\n", user_name, last_value));
return last_value;