mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
added automount home directory support. contributed by simeon@bangor.co.uk
and a mini bug-fix by rob.nacarrato@sheridanc.on.ca reads in an entry from the auto.home file for the user when they log in, and mounts their home directory as the default path for the [homes] service. i might add this as to the %substitution system, so that you can specify subdirectories for the user profiles, mainly. lkcl
This commit is contained in:
parent
1d1143fb6f
commit
0bb6acc358
@ -146,6 +146,7 @@ char *lp_remote_announce(void);
|
||||
char *lp_wins_server(void);
|
||||
char *lp_interfaces(void);
|
||||
char *lp_socket_address(void);
|
||||
char *lp_nis_home_map_name(void);
|
||||
BOOL lp_wins_support(void);
|
||||
BOOL lp_wins_proxy(void);
|
||||
BOOL lp_domain_master(void);
|
||||
@ -163,6 +164,8 @@ BOOL lp_strip_dot(void);
|
||||
BOOL lp_encrypted_passwords(void);
|
||||
BOOL lp_syslog_only(void);
|
||||
BOOL lp_browse_list(void);
|
||||
BOOL lp_unix_realname(void);
|
||||
BOOL lp_nis_home_map(void);
|
||||
int lp_os_level(void);
|
||||
int lp_max_ttl(void);
|
||||
int lp_max_log_size(void);
|
||||
@ -431,9 +434,9 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len);
|
||||
|
||||
void debug_browse_data(char *outbuf, int len);
|
||||
void initiate_netbios_packet(uint16 *id,
|
||||
int fd,int quest_type,char *name,int name_type,
|
||||
int nb_flags,BOOL bcast,BOOL recurse,
|
||||
struct in_addr to_ip);
|
||||
int fd,int quest_type,char *name,int name_type,
|
||||
int nb_flags,BOOL bcast,BOOL recurse,
|
||||
struct in_addr to_ip);
|
||||
void reply_netbios_packet(struct packet_struct *p1,int trn_id,
|
||||
int rcode, int rcv_code, int opcode, BOOL recurse,
|
||||
struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
|
||||
@ -441,8 +444,7 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
|
||||
void queue_packet(struct packet_struct *packet);
|
||||
void run_packet_queue();
|
||||
void listen_for_packets(BOOL run_election);
|
||||
BOOL send_mailslot_reply(BOOL unique, char *mailslot,int fd,
|
||||
char *buf,int len,char *srcname,
|
||||
BOOL send_mailslot_reply(BOOL unique, char *mailslot,int fd,char *buf,int len,char *srcname,
|
||||
char *dstname,int src_type,int dest_type,
|
||||
struct in_addr dest_ip,struct in_addr src_ip);
|
||||
|
||||
@ -468,7 +470,7 @@ struct response_record *queue_netbios_packet(struct subnet_record *d,
|
||||
int fd,int quest_type,enum state_type state,char *name,
|
||||
int name_type,int nb_flags, time_t ttl,
|
||||
int server_type, char *my_name, char *my_comment,
|
||||
BOOL bcast,BOOL recurse,
|
||||
BOOL bcast,BOOL recurse,
|
||||
struct in_addr send_ip, struct in_addr reply_to_ip);
|
||||
|
||||
/*The following definitions come from nameserv.c */
|
||||
|
@ -372,6 +372,10 @@ typedef struct
|
||||
int user_ngroups;
|
||||
gid_t *user_groups;
|
||||
int *user_igroups; /* an integer version - some OSes are broken :-( */
|
||||
#if (defined(NETGROUP) && defined(AUTOMOUNT))
|
||||
char *home_share; /* to store NIS home of a user - simeon */
|
||||
#endif
|
||||
char *real_name; /* to store real name from password file - simeon */
|
||||
} user_struct;
|
||||
|
||||
|
||||
|
@ -135,6 +135,7 @@ typedef struct
|
||||
char *szInterfaces;
|
||||
char *szRemoteAnnounce;
|
||||
char *szSocketAddress;
|
||||
char *szNISHomeMapName;
|
||||
int max_log_size;
|
||||
int mangled_stack;
|
||||
int max_xmit;
|
||||
@ -167,6 +168,8 @@ typedef struct
|
||||
BOOL bReadbmpx;
|
||||
BOOL bSyslogOnly;
|
||||
BOOL bBrowseList;
|
||||
BOOL bUnixRealname;
|
||||
BOOL bNISHomeMap;
|
||||
} global;
|
||||
|
||||
static global Globals;
|
||||
@ -412,6 +415,7 @@ struct parm_struct
|
||||
{"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL},
|
||||
{"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL},
|
||||
{"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL},
|
||||
{"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL},
|
||||
{"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL},
|
||||
{"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL},
|
||||
{"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL},
|
||||
@ -436,7 +440,8 @@ struct parm_struct
|
||||
{"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL},
|
||||
{"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL},
|
||||
{"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL},
|
||||
|
||||
{"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL},
|
||||
{"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL},
|
||||
{"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL},
|
||||
{"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL},
|
||||
{"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy},
|
||||
@ -603,7 +608,11 @@ static void init_globals(void)
|
||||
Globals.bWINSsupport = False;
|
||||
Globals.bWINSproxy = False;
|
||||
Globals.ReadSize = 16*1024;
|
||||
|
||||
Globals.bUnixRealname = False;
|
||||
#ifdef NETGROUP
|
||||
Globals.bNISHomeMap = False;
|
||||
string_set(&Globals.szNISHomeMapName, "auto.home");
|
||||
#endif
|
||||
#ifdef KANJI
|
||||
coding_system = interpret_coding_system (KANJI, SJIS_CODE);
|
||||
#endif /* KANJI */
|
||||
@ -758,6 +767,7 @@ FN_GLOBAL_STRING(lp_remote_announce,&Globals.szRemoteAnnounce)
|
||||
FN_GLOBAL_STRING(lp_wins_server,&Globals.szWINSserver)
|
||||
FN_GLOBAL_STRING(lp_interfaces,&Globals.szInterfaces)
|
||||
FN_GLOBAL_STRING(lp_socket_address,&Globals.szSocketAddress)
|
||||
FN_GLOBAL_STRING(lp_nis_home_map_name,&Globals.szNISHomeMapName)
|
||||
|
||||
FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport)
|
||||
FN_GLOBAL_BOOL(lp_wins_proxy,&Globals.bWINSproxy)
|
||||
@ -776,6 +786,8 @@ FN_GLOBAL_BOOL(lp_strip_dot,&Globals.bStripDot)
|
||||
FN_GLOBAL_BOOL(lp_encrypted_passwords,&Globals.bEncryptPasswords)
|
||||
FN_GLOBAL_BOOL(lp_syslog_only,&Globals.bSyslogOnly)
|
||||
FN_GLOBAL_BOOL(lp_browse_list,&Globals.bBrowseList)
|
||||
FN_GLOBAL_BOOL(lp_unix_realname,&Globals.bUnixRealname)
|
||||
FN_GLOBAL_BOOL(lp_nis_home_map,&Globals.bNISHomeMap)
|
||||
|
||||
FN_GLOBAL_INTEGER(lp_os_level,&Globals.os_level)
|
||||
FN_GLOBAL_INTEGER(lp_max_ttl,&Globals.max_ttl)
|
||||
|
@ -1947,6 +1947,7 @@ There is no auxiliary data in the response.
|
||||
#define AF_OP_SERVER 2
|
||||
#define AF_OP_ACCOUNTS 3
|
||||
|
||||
|
||||
static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
@ -1959,10 +1960,17 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
int uLevel = SVAL(p,0);
|
||||
char *p2;
|
||||
|
||||
*rparam_len = 6;
|
||||
*rparam = REALLOC(*rparam,*rparam_len);
|
||||
/* get NIS home of a previously validated user - simeon */
|
||||
user_struct *vuser = get_valid_user_struct(vuid);
|
||||
DEBUG(3,(" Username of UID %d is %s\n", vuser->uid, vuser->name));
|
||||
#if (defined(NETGROUP) && defined(AUTOMOUNT))
|
||||
DEBUG(3,(" HOMESHR for %s is %s\n", vuser->name, vuser->home_share));
|
||||
#endif
|
||||
|
||||
/* check it's a supported varient */
|
||||
*rparam_len = 6;
|
||||
*rparam = REALLOC(*rparam,*rparam_len);
|
||||
|
||||
/* check it's a supported variant */
|
||||
if (strcmp(str1,"zWrLh") != 0) return False;
|
||||
switch( uLevel )
|
||||
{
|
||||
@ -2005,12 +2013,10 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
|
||||
/* EEK! the cifsrap.txt doesn't have this in!!!! */
|
||||
SIVAL(p,usri11_full_name,PTR_DIFF(p2,p)); /* full name */
|
||||
#if 0
|
||||
strcpy(p2,"FullName");
|
||||
#endif
|
||||
strcpy(p2,UserName); /* suggest copying the user name, for now... */
|
||||
strcpy(p2,vuser->real_name); /* simeon */
|
||||
p2 = skip_string(p2,1);
|
||||
}
|
||||
|
||||
if (uLevel == 11) /* modelled after NTAS 3.51 reply */
|
||||
{
|
||||
SSVAL(p,usri11_priv,Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
@ -2023,7 +2029,11 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (defined(NETGROUP) && defined(AUTOMOUNT))
|
||||
strcpy(p2, vuser->home_share);
|
||||
#else
|
||||
strcpy(p2,"\\\\%L\\%U");
|
||||
#endif
|
||||
}
|
||||
standard_sub_basic(p2);
|
||||
p2 = skip_string(p2,1);
|
||||
@ -2067,7 +2077,11 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (defined(NETGROUP) && defined(AUTOMOUNT))
|
||||
strcpy(p2, vuser->home_share);
|
||||
#else
|
||||
strcpy(p2,"\\\\%L\\%U");
|
||||
#endif
|
||||
}
|
||||
standard_sub_basic(p2);
|
||||
p2 = skip_string(p2,1);
|
||||
@ -2079,7 +2093,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
{
|
||||
SIVAL(p,60,0); /* auth_flags */
|
||||
SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* full_name */
|
||||
strcpy(p2,"<Full Name>");
|
||||
strcpy(p2,vuser->real_name); /* simeon */
|
||||
p2 = skip_string(p2,1);
|
||||
SIVAL(p,68,0); /* urs_comment */
|
||||
SIVAL(p,72,PTR_DIFF(p2,*rdata)); /* parms */
|
||||
@ -3066,5 +3080,3 @@ int reply_trans(char *inbuf,char *outbuf)
|
||||
|
||||
return(outsize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#if (defined(NETGROUP) && defined (AUTOMOUNT))
|
||||
#include "rpcsvc/ypclnt.h"
|
||||
#endif
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern int Protocol;
|
||||
|
||||
@ -138,6 +142,17 @@ uint16 register_vuid(int uid,int gid, char *name,BOOL guest)
|
||||
{
|
||||
user_struct *vuser;
|
||||
|
||||
#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;
|
||||
#endif
|
||||
struct passwd *pwfile; /* for getting real name from passwd file */
|
||||
int real_name_len;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < num_validated_users; i++) {
|
||||
vuser = &validated_users[i];
|
||||
@ -177,6 +192,46 @@ uint16 register_vuid(int uid,int gid, char *name,BOOL guest)
|
||||
|
||||
DEBUG(3,("uid %d registered to name %s\n",uid,name));
|
||||
|
||||
#if (defined(NETGROUP) && defined (AUTOMOUNT))
|
||||
vuser->home_share = NULL;
|
||||
DEBUG(3, ("Setting default HOMESHR to: \\\\logon server\\HOMES\n"));
|
||||
vuser->home_share = Realloc(vuser->home_share, 32);
|
||||
strcpy(vuser->home_share,"\\\\%L\\HOMES");
|
||||
|
||||
if (nis_error = yp_get_default_domain(&nis_domain))
|
||||
DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
|
||||
DEBUG(3, ("NIS Domain: %s\n", nis_domain));
|
||||
|
||||
if (nis_error = yp_match(nis_domain, nis_map, vuser->name, strlen(vuser->name),
|
||||
&nis_result, &nis_result_len))
|
||||
DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
|
||||
if (!nis_error && lp_nis_home_map()) {
|
||||
home_server_len = strcspn(nis_result,":");
|
||||
DEBUG(3, ("NIS lookup succeeded\n\tHome server length: %d\n",home_server_len));
|
||||
vuser->home_share = (char *)Realloc(vuser->home_share, home_server_len+12);
|
||||
DEBUG(3, ("\tAllocated %d bytes for HOMESHR\n",home_server_len+12 ));
|
||||
strcpy(vuser->home_share,"\\\\");
|
||||
strncat(vuser->home_share, nis_result, home_server_len);
|
||||
strcat(vuser->home_share,"\\homes");
|
||||
DEBUG(2,("\tUser = %s\n\tUID = %d\n\tNIS result = %s\n\tHOMESHR = %s\n",
|
||||
vuser->name, vuser->uid, nis_result, vuser->home_share));
|
||||
}
|
||||
#endif
|
||||
|
||||
vuser->real_name = NULL;
|
||||
DEBUG(3, ("Clearing default real name\n"));
|
||||
vuser->real_name = Realloc(vuser->real_name, 15);
|
||||
strcpy(vuser->real_name, "<Full Name>\0");
|
||||
if (lp_unix_realname()) {
|
||||
pwfile=getpwnam(vuser->name);
|
||||
DEBUG(3, ("User name: %s\tReal name: %s\n",vuser->name,pwfile->pw_gecos));
|
||||
real_name_len = strcspn(pwfile->pw_gecos, ",");
|
||||
DEBUG(3, ("Real name length: %d\n", real_name_len));
|
||||
vuser->real_name = (char *)Realloc(vuser->real_name, real_name_len+1);
|
||||
strncpy(vuser->real_name, pwfile->pw_gecos, real_name_len);
|
||||
vuser->real_name[real_name_len]='\0';
|
||||
}
|
||||
|
||||
return (uint16)((num_validated_users - 1) + VUID_OFFSET);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user