summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1996-06-04 06:42:03 +0000
committerAndrew Tridgell <tridge@samba.org>1996-06-04 06:42:03 +0000
commita2c1623827406667a4f2f058c24f1d971f6627f8 (patch)
tree22350c4c3fe902a1b573612d40a6ca4d2be51856 /source3/smbd
parent81e398963dbaed9c6661c336fe98329098576b94 (diff)
downloadsamba-a2c1623827406667a4f2f058c24f1d971f6627f8.tar.gz
samba-a2c1623827406667a4f2f058c24f1d971f6627f8.tar.bz2
samba-a2c1623827406667a4f2f058c24f1d971f6627f8.zip
a huge pile of changes :-)
The biggest thing is the integration of Lukes new nmbd. Its still largely untested, so we will really need some feedback I've also added auto prototype generation and cleaned up a lot of minor things as a result (This used to be commit 0d8dcfa13c527ec2c8aca39ba49c09e4e694b26c)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/password.c2
-rw-r--r--source3/smbd/reply.c8
-rw-r--r--source3/smbd/server.c29
-rw-r--r--source3/smbd/smbrun.c2
-rw-r--r--source3/smbd/trans2.c20
-rw-r--r--source3/smbd/uid.c54
-rw-r--r--source3/smbd/vt_mode.c26
7 files changed, 60 insertions, 81 deletions
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index b8111fc739..31d9191271 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -1258,7 +1258,7 @@ BOOL server_cryptkey(char *buf)
fstring desthost;
struct in_addr dest_ip;
extern struct in_addr myip;
- int port = 139;
+ int port = SMB_PORT;
BOOL ret;
if (password_client >= 0)
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 68376baaf3..4472e120aa 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1928,11 +1928,11 @@ int reply_close(char *inbuf,char *outbuf)
mtime = make_unix_date3(inbuf+smb_vwv1);
- close_file(fnum);
-
/* try and set the date */
set_filetime(Files[fnum].name,mtime);
+ close_file(fnum);
+
/* We have a cached error */
if(eclass || err)
return(ERROR(eclass,err));
@@ -1976,10 +1976,10 @@ int reply_writeclose(char *inbuf,char *outbuf)
nwritten = write_file(fnum,data,numtowrite);
- close_file(fnum);
-
set_filetime(Files[fnum].name,mtime);
+ close_file(fnum);
+
DEBUG(3,("%s writeclose fnum=%d cnum=%d num=%d wrote=%d (numopen=%d)\n",
timestring(),fnum,cnum,numtowrite,nwritten,
Connections[cnum].num_files_open));
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index b8e3cba61c..a8e1dad838 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -139,31 +139,20 @@ mode_t unix_mode(int cnum,int dosmode)
int dos_mode(int cnum,char *path,struct stat *sbuf)
{
int result = 0;
+ extern struct current_user current_user;
-#if OLD_DOS_MODE
- if (!CAN_WRITE(cnum) || !((sbuf->st_mode & S_IWOTH) ||
- Connections[cnum].admin_user ||
- ((sbuf->st_mode & S_IWUSR) &&
- Connections[cnum].uid==sbuf->st_uid) ||
- ((sbuf->st_mode & S_IWGRP) &&
- in_group(sbuf->st_gid,Connections[cnum].gid,
- Connections[cnum].ngroups,
- Connections[cnum].igroups))))
- result |= aRONLY;
-#else
if (CAN_WRITE(cnum) && !lp_alternate_permissions(SNUM(cnum))) {
if (!((sbuf->st_mode & S_IWOTH) ||
Connections[cnum].admin_user ||
- ((sbuf->st_mode & S_IWUSR) && Connections[cnum].uid==sbuf->st_uid) ||
+ ((sbuf->st_mode & S_IWUSR) && current_user.uid==sbuf->st_uid) ||
((sbuf->st_mode & S_IWGRP) &&
- in_group(sbuf->st_gid,Connections[cnum].gid,
- Connections[cnum].ngroups,Connections[cnum].igroups))))
+ in_group(sbuf->st_gid,current_user.gid,
+ current_user.ngroups,current_user.igroups))))
result |= aRONLY;
} else {
if ((sbuf->st_mode & S_IWUSR) == 0)
result |= aRONLY;
}
-#endif
if ((sbuf->st_mode & S_IXUSR) != 0)
result |= aARCH;
@@ -3383,7 +3372,7 @@ int construct_reply(char *inbuf,char *outbuf,int size,int bufsize)
/****************************************************************************
process commands from the client
****************************************************************************/
-void process(void )
+static void process(void)
{
static int trans_num = 0;
int nread;
@@ -3407,7 +3396,7 @@ void process(void )
ip = *interpret_addr2("localhost");
if (zero_ip(ip)) ip = *interpret_addr2("127.0.0.1");
*OutBuffer = 0;
- send_one_packet(OutBuffer,1,ip,137,SOCK_DGRAM);
+ send_one_packet(OutBuffer,1,ip,NMB_PORT,SOCK_DGRAM);
}
#endif
@@ -3592,7 +3581,7 @@ static void init_structs(void )
/****************************************************************************
usage on the program
****************************************************************************/
-void usage(char *pname)
+static void usage(char *pname)
{
DEBUG(0,("Incorrect program usage - are you sure the command line is correct?\n"));
@@ -3612,12 +3601,12 @@ void usage(char *pname)
/****************************************************************************
main program
****************************************************************************/
-int main(int argc,char *argv[])
+ int main(int argc,char *argv[])
{
extern BOOL append_log;
/* shall I run as a daemon */
BOOL is_daemon = False;
- int port = 139;
+ int port = SMB_PORT;
int opt;
extern char *optarg;
diff --git a/source3/smbd/smbrun.c b/source3/smbd/smbrun.c
index 6c9ba52b8b..dcd5379bc1 100644
--- a/source3/smbd/smbrun.c
+++ b/source3/smbd/smbrun.c
@@ -46,7 +46,7 @@ as non root from a program which is switching between root and non-root
It takes 3 arguments as uid,gid,command and runs command after
becoming a non-root user */
-int main(int argc,char *argv[])
+ int main(int argc,char *argv[])
{
int uid,gid;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 045d461184..36dd5eba3e 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -264,7 +264,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
int mode=0;
uint32 size=0,len;
uint32 mdate=0, adate=0, cdate=0;
- char *name_ptr;
+ char *nameptr;
BOOL isrootdir = (strequal(Connections[cnum].dirpath,"./") ||
strequal(Connections[cnum].dirpath,".") ||
strequal(Connections[cnum].dirpath,"/"));
@@ -349,7 +349,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
#endif
p = pdata;
- name_ptr = p;
+ nameptr = p;
name_map_mangle(fname,False,SNUM(cnum));
@@ -368,7 +368,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
SSVAL(p,l1_attrFile,mode);
SCVAL(p,l1_cchName,strlen(fname));
strcpy(p + l1_achName, fname);
- name_ptr = p + l1_achName;
+ nameptr = p + l1_achName;
p += l1_achName + strlen(fname) + 1;
break;
@@ -387,7 +387,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
SIVAL(p,l2_cbList,0); /* No extended attributes */
SCVAL(p,l2_cchName,strlen(fname));
strcpy(p + l2_achName, fname);
- name_ptr = p + l2_achName;
+ nameptr = p + l2_achName;
p += l2_achName + strlen(fname) + 1;
break;
@@ -402,7 +402,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
SIVAL(p,26,4);
CVAL(p,30) = strlen(fname);
strcpy(p+31, fname);
- name_ptr = p+31;
+ nameptr = p+31;
p += 31 + strlen(fname) + 1;
break;
@@ -420,7 +420,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
SSVAL(p,24,mode);
CVAL(p,32) = strlen(fname);
strcpy(p + 33, fname);
- name_ptr = p+33;
+ nameptr = p+33;
p += 33 + strlen(fname) + 1;
break;
@@ -452,7 +452,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
strupper(p+2);
SSVAL(p,0,strlen(p+2));
p += 2 + 24;
- /* name_ptr = p; */
+ /* nameptr = p; */
strcpy(p,fname); p += strlen(p);
p = pdata + len;
break;
@@ -517,7 +517,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
}
/* Setup the last_filename pointer, as an offset from base_data */
- *last_name_off = PTR_DIFF(name_ptr,base_data);
+ *last_name_off = PTR_DIFF(nameptr,base_data);
/* Advance the data pointer to the next slot */
*ppdata = p;
return(found);
@@ -1004,7 +1004,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
if (tran_call == TRANSACT2_QFILEINFO) {
- int16 fnum = SVAL(params,0);
+ int16 fnum = SVALS(params,0);
info_level = SVAL(params,2);
CHECK_FNUM(fnum,cnum);
@@ -1198,7 +1198,7 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
return(ERROR(ERRSRV,ERRaccess));
if (tran_call == TRANSACT2_SETFILEINFO) {
- int16 fnum = SVAL(params,0);
+ int16 fnum = SVALS(params,0);
info_level = SVAL(params,2);
CHECK_FNUM(fnum,cnum);
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index f287c733c4..625303350a 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -30,23 +30,18 @@ static int initial_uid;
static int initial_gid;
static int old_umask = 022;
-int current_uid;
-int current_gid;
-
static pstring OriginalDir;
-/* have I done a become_user? */
-static struct {
- int cnum, uid;
-} last_user;
+/* what user is current? */
+struct current_user current_user;
/****************************************************************************
initialise the uid routines
****************************************************************************/
void init_uid(void)
{
- initial_uid = current_uid = geteuid();
- initial_gid = current_gid = getegid();
+ initial_uid = current_user.uid = geteuid();
+ initial_gid = current_user.gid = getegid();
if (initial_gid != 0 && initial_uid == 0)
{
@@ -61,7 +56,7 @@ void init_uid(void)
initial_uid = geteuid();
initial_gid = getegid();
- last_user.cnum = -1;
+ current_user.cnum = -1;
GetWd(OriginalDir);
}
@@ -111,7 +106,7 @@ static BOOL become_uid(int uid)
return(False);
}
- current_uid = uid;
+ current_user.uid = uid;
return(True);
}
@@ -140,7 +135,7 @@ static BOOL become_gid(int gid)
return(False);
}
- current_gid = gid;
+ current_user.gid = gid;
return(True);
}
@@ -174,7 +169,7 @@ BOOL become_guest(void)
if (!ret)
DEBUG(1,("Failed to become guest. Invalid guest account?\n"));
- last_user.cnum = -2;
+ current_user.cnum = -2;
return(ret);
}
@@ -208,10 +203,9 @@ BOOL become_user(int cnum, int uid)
int new_umask;
user_struct *vuser;
int snum,gid;
- int ngroups;
- gid_t *groups;
+ int id = uid;
- if (last_user.cnum == cnum && last_user.uid == uid) {
+ if (current_user.cnum == cnum && current_user.id == id) {
DEBUG(4,("Skipping become_user - already user\n"));
return(True);
}
@@ -231,8 +225,9 @@ BOOL become_user(int cnum, int uid)
!check_user_ok(cnum,vuser,snum)) {
uid = Connections[cnum].uid;
gid = Connections[cnum].gid;
- groups = Connections[cnum].groups;
- ngroups = Connections[cnum].ngroups;
+ current_user.groups = Connections[cnum].groups;
+ current_user.igroups = Connections[cnum].igroups;
+ current_user.ngroups = Connections[cnum].ngroups;
} else {
if (!vuser) {
DEBUG(2,("Invalid vuid used %d\n",uid));
@@ -243,8 +238,9 @@ BOOL become_user(int cnum, int uid)
gid = vuser->gid;
else
gid = Connections[cnum].gid;
- groups = vuser->user_groups;
- ngroups = vuser->user_ngroups;
+ current_user.groups = vuser->user_groups;
+ current_user.igroups = vuser->user_igroups;
+ current_user.ngroups = vuser->user_ngroups;
}
if (initial_uid == 0)
@@ -254,8 +250,8 @@ BOOL become_user(int cnum, int uid)
#ifndef NO_SETGROUPS
if (!IS_IPC(cnum)) {
/* groups stuff added by ih/wreu */
- if (ngroups > 0)
- if (setgroups(ngroups,groups)<0)
+ if (current_user.ngroups > 0)
+ if (setgroups(current_user.ngroups,current_user.groups)<0)
DEBUG(0,("setgroups call failed!\n"));
}
#endif
@@ -267,8 +263,8 @@ BOOL become_user(int cnum, int uid)
new_umask = 0777 & ~CREATE_MODE(cnum);
old_umask = umask(new_umask);
- last_user.cnum = cnum;
- last_user.uid = uid;
+ current_user.cnum = cnum;
+ current_user.id = id;
DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d) new_umask=0%o\n",
getuid(),geteuid(),getgid(),getegid(),new_umask));
@@ -281,7 +277,7 @@ BOOL become_user(int cnum, int uid)
****************************************************************************/
BOOL unbecome_user(void )
{
- if (last_user.cnum == -1)
+ if (current_user.cnum == -1)
return(False);
ChDir(OriginalDir);
@@ -320,8 +316,8 @@ BOOL unbecome_user(void )
}
#endif
- current_uid = initial_uid;
- current_gid = initial_gid;
+ current_user.uid = initial_uid;
+ current_user.gid = initial_gid;
if (ChDir(OriginalDir) != 0)
DEBUG(0,("%s chdir(%s) failed in unbecome_user\n",
@@ -330,7 +326,7 @@ BOOL unbecome_user(void )
DEBUG(5,("unbecome_user now uid=(%d,%d) gid=(%d,%d)\n",
getuid(),geteuid(),getgid(),getegid()));
- last_user.cnum = -1;
+ current_user.cnum = -1;
return(True);
}
@@ -352,7 +348,7 @@ int smbrun(char *cmd,char *outfile)
}
sprintf(syscmd,"%s %d %d \"(%s 2>&1) > %s\"",
- path,current_uid,current_gid,cmd,
+ path,current_user.uid,current_user.gid,cmd,
outfile?outfile:"/dev/null");
DEBUG(5,("smbrun - running %s ",syscmd));
diff --git a/source3/smbd/vt_mode.c b/source3/smbd/vt_mode.c
index 83b62a38ac..0a4d50c217 100644
--- a/source3/smbd/vt_mode.c
+++ b/source3/smbd/vt_mode.c
@@ -60,8 +60,7 @@ int ms_type = MS_NONE,
/*
VT_Check: test incoming packet for "vtp" or "iVT1\0"
*/
-int VT_Check(buffer)
-char *buffer;
+int VT_Check(char *buffer)
{
DEBUG(3,("Checking packet: <%10s...>\n", buffer+4));
if((strncmp(buffer+4, "vtp", 3) == 0 && smb_len(buffer) == 3) || (strncmp(buffer+4, "iVT1\0", 5) == 0 && smb_len(buffer) == 5))
@@ -74,7 +73,7 @@ char *buffer;
/*
VT_Start_utmp: prepare /etc/utmp for /bin/login
*/
-VT_Start_utmp()
+int VT_Start_utmp(void)
{
struct utmp u, *v;
char *tt;
@@ -111,7 +110,7 @@ VT_Start_utmp()
/*
VT_Stop_utmp: prepare /etc/utmp for other processes
*/
-VT_Stop_utmp()
+int VT_Stop_utmp(void)
{
struct utmp u, *v;
@@ -138,7 +137,7 @@ VT_Stop_utmp()
/*
VT_AtExit: Things to do when the program exits
*/
-void VT_AtExit()
+void VT_AtExit(void)
{
if(VT_ChildPID > 0) {
kill(VT_ChildPID, SIGHUP);
@@ -152,8 +151,7 @@ void VT_AtExit()
/*
VT_SigCLD: signalhandler for SIGCLD: set flag if child-process died
*/
-void VT_SigCLD(sig)
-int sig;
+void VT_SigCLD(int sig)
{
if(wait(NULL) == VT_ChildPID)
VT_ChildDied = True;
@@ -165,8 +163,7 @@ int sig;
/*
VT_SigEXIT: signalhandler for signals that cause the process to exit
*/
-void VT_SigEXIT(sig)
-int sig;
+void VT_SigEXIT(int sig)
{
VT_AtExit();
@@ -177,7 +174,7 @@ int sig;
/*
VT_Start: initialize vt-specific data, alloc pty, spawn shell and send ACK
*/
-int VT_Start()
+int VT_Start(void)
{
char OutBuf [64], *X, *Y;
@@ -330,8 +327,7 @@ int VT_Start()
/*
VT_Output: transport data from socket to pty
*/
-int VT_Output(Buffer)
-char *Buffer;
+int VT_Output(char *Buffer)
{
int i, len, nb;
@@ -350,9 +346,7 @@ char *Buffer;
/*
VT_Input: transport data from pty to socket
*/
-int VT_Input(Buffer, Size)
-char *Buffer;
-int Size;
+int VT_Input(char *Buffer,int Size)
{
int len;
@@ -372,7 +366,7 @@ int Size;
/*
VT_Process: main loop while in vt-mode
*/
-void VT_Process()
+void VT_Process(void)
{
static int trans_num = 0;
extern int Client;