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 | c6c28a4c3c9010ff9d5eac4bad091189a786d5a0 (patch) | |
tree | 1b3c593a861a3d80ae94597d09ab49027a45efb4 /source/lib | |
parent | 53a8a6ced58429886fef019a56c9059e0dcb6622 (diff) | |
download | samba-c6c28a4c3c9010ff9d5eac4bad091189a786d5a0.tar.gz |
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.
Diffstat (limited to 'source/lib')
-rw-r--r-- | source/lib/util.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/source/lib/util.c b/source/lib/util.c index 5c243204d02..9295d9ae73f 100644 --- a/source/lib/util.c +++ b/source/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; |