summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in52
-rw-r--r--source3/bin/.cvsignore4
-rw-r--r--source3/include/proto.h102
-rw-r--r--source3/utils/smbrun.c92
4 files changed, 199 insertions, 51 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index b093003550..e1e1aea517 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -117,10 +117,10 @@ LOCKING_OBJ = locking/locking.o locking/locking_shm.o locking/locking_slow.o \
locking/shmem.o locking/shmem_sysv.o
PASSDB_OBJ = passdb/passdb.o passdb/smbpassfile.o passdb/username.o \
- passdb/smbpass.o passdb/password.o
+ passdb/smbpass.o
SMBD_OBJ1 = smbd/server.o smbd/access.o smbd/chgpasswd.o smbd/connection.o \
- smbd/dfree.o smbd/dir.o \
+ smbd/dfree.o smbd/dir.o smbd/password.o \
smbd/groupname.o smbd/ipc.o smbd/ldap.o smbd/mangle.o \
smbd/message.o smbd/nispass.o smbd/nttrans.o \
smbd/pipes.o smbd/predict.o \
@@ -149,13 +149,24 @@ NMBD_OBJ = $(NMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
$(PASSDB_OBJ) $(LIB_OBJ)
SWAT_OBJ = web/cgi.o web/diagnose.o web/startstop.o web/statuspage.o \
- web/swat.o $(PASSDB_OBJ) $(LIBSMB_OBJ) $(LOCKING_OBJ) \
+ web/swat.o \
+ smbd/password.o \
+ $(PASSDB_OBJ) $(LIBSMB_OBJ) $(LOCKING_OBJ) \
$(PARAM_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
$(UBIQX_OBJ) $(LIB_OBJ)
-PROTO_OBJ = $(SMBD_OBJ1) $(NMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
- $(RPC_SERVER_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
- $(LOCKING_OBJ) $(PASSDB_OBJ) $(SWAT_OBJ) $(LIB_OBJ)
+SMBRUN_OBJ = utils/smbrun.o
+
+TESTPARM_OBJ = utils/testparm.o smbd/access.o $(PARAM_OBJ) $(PASSDB_OBJ) \
+ $(UBIQX_OBJ) $(LIB_OBJ)
+
+TESTPRNS_OBJ = utils/testprns.o $(PARAM_OBJ) $(UBIQX_OBJ) $(PASSDB_OBJ) \
+ $(LIB_OBJ)
+
+CLIENT_OBJ = client/client.o client/clientutil.o client/clitar.o \
+ $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(PASSDB_OBJ) $(LIB_OBJ)
+
+PROTO_OBJ = $(SMBD_OBJ) $(NMBD_OBJ) $(SWAT_OBJ) $(CLIENT_OBJ)
######################################################################
# now the rules...
@@ -182,18 +193,27 @@ bin/swat: $(SWAT_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LIBS)
-bin/smbrun: utils/smbrun.o
+bin/smbrun: $(SMBRUN_OBJ)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SMBRUN_OBJ) $(LIBS)
+
+bin/smbclient: $(CLIENT_OBJ)
@echo Linking $@
- @$(CC) $(FLAGS) -o $@ utils/smbrun.o $(LIBS)
+ @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LIBS)
+
+bin/testparm: $(TESTPARM_OBJ)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LIBS)
+
+bin/testprns: $(TESTPRNS_OBJ)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(TESTPRNS_OBJ) $(LIBS)
+
nmblookup: $(LOOKUP_OBJ)
@echo Linking nmblookup
@$(CC) $(FLAGS) -o nmblookup $(LOOKUP_OBJ) $(LIBS)
-smbclient: $(CLIENT_OBJ)
- @echo Linking smbclient
- @$(CC) $(FLAGS) -o smbclient $(CLIENT_OBJ) $(LIBS)
-
smbmount: $(MOUNT_OBJ)
@echo Linking smbmount
@$(CC) $(FLAGS) -o smbmount $(MOUNT_OBJ) $(LIBS)
@@ -214,14 +234,6 @@ smbstatus: $(STATUS_OBJ)
@echo Linking smbstatus
@$(CC) $(FLAGS) -o smbstatus $(STATUS_OBJ) $(LIBS)
-testparm: testparm.o access.o $(UTILOBJ)
- @echo Linking testparm
- @$(CC) $(FLAGS) -o testparm testparm.o access.o $(UTILOBJ) $(LIBS)
-
-testprns: testprns.o $(UTILOBJ)
- @echo Linking testprns
- @$(CC) $(FLAGS) -o testprns testprns.o $(UTILOBJ) $(LIBS)
-
smbpasswd: smbpasswd.o getsmbpass.o $(PASSDB_OBJ) $(UTILOBJ) $(CLIENTUTIL) $(RPC_CLIENT_SERVER_SUBSET_OBJ) $(RPC_OBJ)
@echo Linking smbpasswd
@$(CC) $(FLAGS) -o smbpasswd smbpasswd.o getsmbpass.o $(PASSDB_OBJ) $(UTILOBJ) $(CLIENTUTIL) \
diff --git a/source3/bin/.cvsignore b/source3/bin/.cvsignore
index 777b59da1a..753138a322 100644
--- a/source3/bin/.cvsignore
+++ b/source3/bin/.cvsignore
@@ -1,3 +1,7 @@
nmbd
+smbclient
smbd
+smbrun
swat
+testparm
+testprns
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 022c0a93c2..558e17acab 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3,6 +3,46 @@
/* This file is automatically generated with "make proto". DO NOT EDIT */
+/*The following definitions come from client/client.c */
+
+void cli_smb_close(char *inbuf, char *outbuf, int clnt_fd, int c_num, int f_num);
+void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(file_info *),BOOL recurse_dir, BOOL dirstoo);
+void cmd_help(char *dum_in, char *dum_out);
+
+/*The following definitions come from client/clientutil.c */
+
+void cli_setup_pkt(char *outbuf);
+BOOL cli_call_api(char *pipe_name, int pipe_name_len,
+ int prcnt,int drcnt, int srcnt,
+ int mprcnt,int mdrcnt,
+ int *rprcnt,int *rdrcnt,
+ char *param,char *data, uint16 *setup,
+ char **rparam,char **rdata);
+BOOL cli_receive_trans_response(char *inbuf,int trans,
+ int *data_len,int *param_len,
+ char **data,char **param);
+BOOL cli_send_trans_request(char *outbuf,int trans,
+ char *name,int namelen, int fid,int flags,
+ char *data,char *param,uint16 *setup,
+ int ldata,int lparam,int lsetup,
+ int mdata,int mparam,int msetup);
+BOOL cli_send_session_request(char *inbuf,char *outbuf);
+BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, struct connection_options *options);
+void cli_send_logout(char *dum_in, char *dum_out);
+BOOL cli_open_sockets(int port );
+BOOL cli_reopen_connection(char *inbuf,char *outbuf);
+
+/*The following definitions come from client/clitar.c */
+
+int padit(char *buf, int bufsize, int padsize);
+void cmd_block(char *dum_in, char *dum_out);
+void cmd_tarmode(char *dum_in, char *dum_out);
+void cmd_setmode(char *dum_in, char *dum_out);
+void cmd_tar(char *inbuf, char *outbuf);
+int process_tar(char *inbuf, char *outbuf);
+int clipfind(char **aret, int ret, char *tok);
+int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind);
+
/*The following definitions come from lib/charcnv.c */
char *unix2dos_format(char *str,BOOL overwrite);
@@ -1079,37 +1119,6 @@ uint32 pdb_gid_to_group_rid(gid_t gid);
BOOL pdb_rid_is_well_known(uint32 rid);
BOOL pdb_rid_is_user(uint32 rid);
-/*The following definitions come from passdb/password.c */
-
-void generate_next_challenge(char *challenge);
-BOOL set_challenge(char *challenge);
-BOOL last_challenge(unsigned char *challenge);
-user_struct *get_valid_user_struct(uint16 vuid);
-void invalidate_vuid(uint16 vuid);
-char *validated_username(uint16 vuid);
-int setup_groups(char *user, int uid, int gid, int *p_ngroups, GID_T **p_groups);
-uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOOL guest);
-void add_session_user(char *user);
-BOOL update_smbpassword_file( char *user, fstring password);
-void dfs_unlogin(void);
-BOOL password_check(char *password);
-BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned char *c8);
-BOOL smb_password_ok(struct smb_passwd *smb_pass,
- uchar lm_pass[24], uchar nt_pass[24]);
-BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd);
-BOOL user_ok(char *user,int snum);
-BOOL authorise_login(int snum,char *user,char *password, int pwlen,
- BOOL *guest,BOOL *force,uint16 vuid);
-BOOL check_hosts_equiv(char *user);
-struct cli_state *server_client(void);
-struct cli_state *server_cryptkey(void);
-BOOL server_validate(char *user, char *domain,
- char *pass, int passlen,
- char *ntpass, int ntpasslen);
-BOOL domain_client_validate( char *user, char *domain,
- char *smb_apasswd, int smb_apasslen,
- char *smb_ntpasswd, int smb_ntpasslen);
-
/*The following definitions come from passdb/smbpass.c */
struct passdb_ops *file_initialize_password_db(void);
@@ -1927,6 +1936,37 @@ void remove_pending_change_notify_requests_by_mid(int mid);
void process_pending_change_notify_queue(time_t t);
int reply_nttrans(char *inbuf,char *outbuf,int length,int bufsize);
+/*The following definitions come from smbd/password.c */
+
+void generate_next_challenge(char *challenge);
+BOOL set_challenge(char *challenge);
+BOOL last_challenge(unsigned char *challenge);
+user_struct *get_valid_user_struct(uint16 vuid);
+void invalidate_vuid(uint16 vuid);
+char *validated_username(uint16 vuid);
+int setup_groups(char *user, int uid, int gid, int *p_ngroups, GID_T **p_groups);
+uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOOL guest);
+void add_session_user(char *user);
+BOOL update_smbpassword_file( char *user, fstring password);
+void dfs_unlogin(void);
+BOOL password_check(char *password);
+BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned char *c8);
+BOOL smb_password_ok(struct smb_passwd *smb_pass,
+ uchar lm_pass[24], uchar nt_pass[24]);
+BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd);
+BOOL user_ok(char *user,int snum);
+BOOL authorise_login(int snum,char *user,char *password, int pwlen,
+ BOOL *guest,BOOL *force,uint16 vuid);
+BOOL check_hosts_equiv(char *user);
+struct cli_state *server_client(void);
+struct cli_state *server_cryptkey(void);
+BOOL server_validate(char *user, char *domain,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen);
+BOOL domain_client_validate( char *user, char *domain,
+ char *smb_apasswd, int smb_apasslen,
+ char *smb_ntpasswd, int smb_ntpasslen);
+
/*The following definitions come from smbd/pipes.c */
int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize);
diff --git a/source3/utils/smbrun.c b/source3/utils/smbrun.c
new file mode 100644
index 0000000000..2a94ac3235
--- /dev/null
+++ b/source3/utils/smbrun.c
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ external program running routine
+ Copyright (C) Andrew Tridgell 1992-1998
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+/*******************************************************************
+close the low 3 fd's and open dev/null in their place
+********************************************************************/
+static void close_fds(void)
+{
+ int fd;
+ int i;
+ close(0); close(1); close(2);
+ /* try and use up these file descriptors, so silly
+ library routines writing to stdout etc won't cause havoc */
+ for (i=0;i<3;i++) {
+ fd = open("/dev/null",O_RDWR,0);
+ if (fd < 0) fd = open("/dev/null",O_WRONLY,0);
+ if (fd != i) return;
+ }
+}
+
+
+/*
+This is a wrapper around the system() call to allow commands to run correctly
+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 uid,gid;
+
+ close_fds();
+
+ if (argc != 4) exit(2);
+
+ uid = atoi(argv[1]);
+ gid = atoi(argv[2]);
+
+ /* first become root - we may need to do this in order to lose
+ our privilages! */
+#ifdef HAVE_SETRESUID
+ setresgid(0,0,0);
+ setresuid(0,0,0);
+#else
+ setuid(0);
+ seteuid(0);
+#endif
+
+#ifdef HAVE_SETRESUID
+ setresgid(gid,gid,gid);
+ setresuid(uid,uid,uid);
+#else
+ setgid(gid);
+ setegid(gid);
+ setuid(uid);
+ seteuid(uid);
+#endif
+
+
+ /* paranoia :-) */
+ if (getuid() != uid)
+ return(3);
+
+ if (geteuid() != getuid())
+ return(4);
+
+ /* this is to make sure that the system() call doesn't run forever */
+ alarm(30);
+
+ return(system(argv[3]));
+}