diff options
author | Luke Leighton <lkcl@samba.org> | 1997-10-20 12:10:58 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1997-10-20 12:10:58 +0000 |
commit | 423a7c417136af3f6d09b3c1763336dd0a401d4f (patch) | |
tree | 85684440ac212cb67b59531cecbab24992aac5f8 /source3/lib | |
parent | 65ae39226c06e54c3237dd53f4be55b7449000e1 (diff) | |
download | samba-423a7c417136af3f6d09b3c1763336dd0a401d4f.tar.gz samba-423a7c417136af3f6d09b3c1763336dd0a401d4f.tar.bz2 samba-423a7c417136af3f6d09b3c1763336dd0a401d4f.zip |
util.c password.c :
added automount_server() function which, if -DAUTOMOUNT is in use,
returns the server name of the NIS auto.map entry. otherwise,
it returns local_server.
added use of automount_server() for a new substitution %N for NIS
home server. this defaults, via automount_server(), to the same
functionality as %L if -DAUTOMOUNT is not used.
removed vuser->home_share. moved code that grabbed the servername
into the separate function automount_server().
loadparm.c :
created "logon drive" (default of "")
created "logon home" (default of "\\%N\%U")
changed default of "logon path" from NULL to "\\%N\%U\profile".
ipc.c pipenetlog.c :
use lp_logon_drive(), lp_logon_home() and lp_logon_path() in their
now easier-to-use form (don't have to check if *lp_logon_path() and
manually substitute a default of \\%L\%U and do a standard_sub_basic()
on the result, because the default automatically does this.
(This used to be commit c6c28a4c3c9010ff9d5eac4bad091189a786d5a0)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 5c243204d0..9295d9ae73 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -21,6 +21,10 @@ #include "includes.h" +#if (defined(NETGROUP) && defined (AUTOMOUNT)) +#include "rpcsvc/ypclnt.h" +#endif + pstring scope = ""; int DEBUGLEVEL = 1; @@ -3602,6 +3606,55 @@ char *client_addr(void) return addr_buf; } +char *automount_server(char *user_name) +{ + static pstring server_name; + +#if (defined(NETGROUP) && defined (AUTOMOUNT)) + int nis_error; /* returned by yp all functions */ + char *nis_result; /* yp_match inits this */ + int nis_result_len; /* and set this */ + char *nis_domain; /* yp_get_default_domain inits this */ + char *nis_map = (char *)lp_nis_home_map_name(); + int home_server_len; + + /* set to default of no string */ + server_name[0] = 0; + + if ((nis_error = yp_get_default_domain(&nis_domain)) != 0) + { + DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error))); + } + + DEBUG(5, ("NIS Domain: %s\n", nis_domain)); + + 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\n", yperr_string(nis_error))); + } + + if (!nis_error && lp_nis_home_map()) + { + home_server_len = strcspn(nis_result,":"); + DEBUG(5, ("NIS lookup succeeded. Home server length: %d\n",home_server_len)); + if (home_server_len > sizeof(pstring)) + { + home_server_len = sizeof(pstring); + } + strncpy(server_name, nis_result, home_server_len); + } +#else + /* use the local machine name instead of the auto-map server */ + pstrcpy(server_name, local_machine); +#endif + + DEBUG(4,("Home server: %s\n", server_name)); + + return server_name; +} + /******************************************************************* sub strings with useful parameters Rewritten by Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and @@ -3630,6 +3683,7 @@ void standard_sub_basic(char *str) } break; } + case 'N' : string_sub(p,"%N", automount_server(username)); break; case 'I' : string_sub(p,"%I", client_addr()); break; case 'L' : string_sub(p,"%L", local_machine); break; case 'M' : string_sub(p,"%M", client_name()); break; |