mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
this is the bug change to using connection_struct* instead of cnum.
Connections[] is now a local array in server.c I might have broken something with this change. In particular the oplock code is suspect and some .dll files aren't being oplocked when I expected them to be. I'll look at it after I've got some sleep. (This used to be commit c7ee025ead4a85b6fa44a832047b878451845fb6)
This commit is contained in:
parent
58fb3c31c0
commit
b9623ab59e
@ -88,12 +88,12 @@ LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \
|
||||
lib/getsmbpass.o lib/interface.o lib/kanji.o lib/md4.o \
|
||||
lib/membuffer.o lib/netmask.o lib/pidfile.o lib/replace.o \
|
||||
lib/signal.o lib/slprintf.o lib/system.o lib/time.o lib/ufc.o \
|
||||
lib/util.o lib/genrand.o lib/username.o lib/access.o
|
||||
lib/util.o lib/genrand.o lib/username.o lib/access.o lib/smbrun.o
|
||||
|
||||
UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \
|
||||
ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o
|
||||
|
||||
PARAM_OBJ = param/loadparm.o param/params.o param/pcap.o smbd/print_svid.o
|
||||
PARAM_OBJ = param/loadparm.o param/params.o
|
||||
|
||||
LIBSMB_OBJ = libsmb/clientgen.o libsmb/namequery.o libsmb/nmblib.o \
|
||||
libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o \
|
||||
@ -118,18 +118,19 @@ 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/smbpass.o \
|
||||
passdb/pass_check.o
|
||||
passdb/pass_check.o passdb/ldap.o passdb/nispass.o
|
||||
|
||||
SMBD_OBJ1 = smbd/server.o smbd/chgpasswd.o smbd/connection.o \
|
||||
smbd/dfree.o smbd/dir.o smbd/password.o \
|
||||
smbd/groupname.o smbd/ipc.o passdb/ldap.o smbd/mangle.o \
|
||||
smbd/message.o passdb/nispass.o smbd/nttrans.o \
|
||||
smbd/pipes.o smbd/predict.o smbd/printing.o \
|
||||
smbd/groupname.o smbd/ipc.o smbd/mangle.o \
|
||||
smbd/message.o smbd/nttrans.o smbd/pipes.o smbd/predict.o \
|
||||
smbd/quotas.o smbd/reply.o smbd/ssl.o smbd/trans2.o smbd/uid.o
|
||||
|
||||
PRINTING_OBJ = param/pcap.o smbd/print_svid.o smbd/printing.o
|
||||
|
||||
SMBD_OBJ = $(SMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
|
||||
$(RPC_SERVER_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
|
||||
$(LOCKING_OBJ) $(PASSDB_OBJ) $(LIB_OBJ)
|
||||
$(LOCKING_OBJ) $(PASSDB_OBJ) $(PRINTING_OBJ) $(LIB_OBJ)
|
||||
|
||||
|
||||
NMBD_OBJ1 = nmbd/asyncdns.o nmbd/nmbd.o nmbd/nmbd_become_dmb.o \
|
||||
@ -167,7 +168,7 @@ STATUS_OBJ = utils/status.o $(LOCKING_OBJ) $(PARAM_OBJ) \
|
||||
TESTPARM_OBJ = utils/testparm.o \
|
||||
$(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
|
||||
|
||||
TESTPRNS_OBJ = utils/testprns.o $(PARAM_OBJ) $(UBIQX_OBJ) \
|
||||
TESTPRNS_OBJ = utils/testprns.o $(PARAM_OBJ) $(PRINTING_OBJ) $(UBIQX_OBJ) \
|
||||
$(LIB_OBJ)
|
||||
|
||||
SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(PASSDB_OBJ) \
|
||||
|
@ -52,3 +52,5 @@
|
||||
#undef REPLACE_INET_NTOA
|
||||
#undef HAVE_FILE_MACRO
|
||||
#undef HAVE_FUNCTION_MACRO
|
||||
#undef HAVE_SETRESUID_DECL
|
||||
#undef WITH_NETATALK
|
||||
|
@ -297,12 +297,12 @@ static long readtarheader(union hblock *hb, file_info2 *finfo, char *prefix)
|
||||
|
||||
fchk=unoct(hb->dbuf.chksum, sizeof(hb->dbuf.chksum));
|
||||
|
||||
DEBUG(5, ("checksum totals chk=%d fchk=%d chksum=%s\n",
|
||||
DEBUG(5, ("checksum totals chk=%ld fchk=%ld chksum=%s\n",
|
||||
chk, fchk, hb->dbuf.chksum));
|
||||
|
||||
if (fchk != chk)
|
||||
{
|
||||
DEBUG(0, ("checksums don't match %d %d\n", fchk, chk));
|
||||
DEBUG(0, ("checksums don't match %ld %ld\n", fchk, chk));
|
||||
/* for (i = 0; i < sizeof(hb -> dummy); i++) {
|
||||
fprintf(stdout, "%2X ", hb -> dummy[i]);
|
||||
}
|
||||
@ -840,7 +840,7 @@ static BOOL smbshut(file_info2 finfo, int fnum, char *inbuf, char *outbuf)
|
||||
SSVAL(outbuf,smb_vwv0,fnum);
|
||||
put_dos_date3(outbuf,smb_vwv1,finfo.mtime);
|
||||
|
||||
DEBUG(3,("Setting date to %s (0x%X)",
|
||||
DEBUG(3,("Setting date to %s (0x%lX)",
|
||||
asctime(LocalTime(&finfo.mtime)),
|
||||
finfo.mtime));
|
||||
|
||||
@ -1517,7 +1517,7 @@ static void unfixtarname(char *tptr, char *fp, int l, BOOL first)
|
||||
* dos \'s in path. Kill any absolute path names. But only if first!
|
||||
*/
|
||||
|
||||
DEBUG(5, ("firstb=%X, secondb=%X, len=%i\n", tptr, fp, l));
|
||||
DEBUG(5, ("firstb=%lX, secondb=%lX, len=%i\n", tptr, fp, l));
|
||||
|
||||
if (first) {
|
||||
if (*fp == '.') {
|
||||
@ -1829,7 +1829,8 @@ static void do_tarput()
|
||||
finfo.name = NULL;
|
||||
|
||||
}
|
||||
DEBUG(5, ("Tarbuf=%X, buffer=%X, endofbuf=%X\n", tarbuf, buffer_p, endofbuffer));
|
||||
DEBUG(5, ("Tarbuf=%X, buffer=%X, endofbuf=%X\n",
|
||||
(int)tarbuf, (int)buffer_p, (int)endofbuffer));
|
||||
switch (readtarheader((union hblock *) buffer_p, &finfo, cur_dir))
|
||||
{
|
||||
case -2: /* something dodgy but not fatal about this */
|
||||
@ -1899,7 +1900,8 @@ static void do_tarput()
|
||||
cp = longname + strlen(cur_dir);
|
||||
file_len = finfo.size;
|
||||
|
||||
DEBUG(5, ("longname=%0X, cp=%0X, file_len=%i\n", longname, cp, file_len));
|
||||
DEBUG(5, ("longname=%0X, cp=%0X, file_len=%i\n",
|
||||
(int)longname, (int)cp, file_len));
|
||||
|
||||
while (file_len > 0) {
|
||||
|
||||
@ -1917,7 +1919,7 @@ static void do_tarput()
|
||||
cp = cp + strlen(cp); /* Move to end of string */
|
||||
buffer_p += TBLOCK;
|
||||
file_len -= TBLOCK;
|
||||
DEBUG(5, ("cp=%0X, file_len=%i\n", cp, file_len));
|
||||
DEBUG(5, ("cp=%0X, file_len=%i\n", (int)cp, file_len));
|
||||
next_header = 1; /* Force read of next header */
|
||||
|
||||
}
|
||||
@ -2045,7 +2047,7 @@ static void do_tarput()
|
||||
}
|
||||
if (fsize % TBLOCK) buffer_p+=TBLOCK - (fsize % TBLOCK);
|
||||
DEBUG(5, ("buffer_p is now %d (psn=%d)\n",
|
||||
(long) buffer_p, (long)(buffer_p - tarbuf)));
|
||||
(int) buffer_p, (int)(buffer_p - tarbuf)));
|
||||
ntarf++;
|
||||
fsize=0;
|
||||
|
||||
|
544
source3/configure
vendored
544
source3/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -58,6 +58,12 @@ AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
|
||||
echo yes; AC_DEFINE(HAVE_ERRNO_DECL),
|
||||
echo no)
|
||||
|
||||
# stupid glibc has the functions but no declaration. grrrr.
|
||||
echo $ac_n "checking for setresuid declaration $ac_c"
|
||||
AC_TRY_COMPILE([#include <unistd.h>],[int i = setresuid],
|
||||
echo yes; AC_DEFINE(HAVE_SETRESUID_DECL),
|
||||
echo no)
|
||||
|
||||
AC_FUNC_MEMCMP
|
||||
|
||||
###############################################
|
||||
|
@ -109,6 +109,8 @@
|
||||
#undef REPLACE_INET_NTOA
|
||||
#undef HAVE_FILE_MACRO
|
||||
#undef HAVE_FUNCTION_MACRO
|
||||
#undef HAVE_SETRESUID_DECL
|
||||
#undef WITH_NETATALK
|
||||
|
||||
/* The number of bytes in a int. */
|
||||
#undef SIZEOF_INT
|
||||
|
@ -464,4 +464,10 @@ time_t mktime(struct tm *t);
|
||||
int ftruncate(int f,long l);
|
||||
#endif
|
||||
|
||||
#if (defined(HAVE_SETRESUID) && !defined(HAVE_SETRESUID_DECL))
|
||||
/* stupid glibc */
|
||||
int setresuid(uid_t ruid, uid_t euid, uid_t suid);
|
||||
int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
|
||||
#endif
|
||||
|
||||
#endif /* _INCLUDES_H */
|
||||
|
@ -55,7 +55,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int cnum;
|
||||
connection_struct *conn;
|
||||
int uid;
|
||||
BOOL open; /* open connection */
|
||||
uint16 device_state;
|
||||
@ -79,7 +79,6 @@ typedef struct
|
||||
uint32 hdr_offsets;
|
||||
uint32 frag_len_left;
|
||||
uint32 next_frag_start;
|
||||
|
||||
} pipes_struct;
|
||||
|
||||
struct acct_info
|
||||
|
@ -148,6 +148,10 @@ void CatchChild(void);
|
||||
|
||||
int vslprintf(char *str, int n, char *format, va_list ap);
|
||||
|
||||
/*The following definitions come from lib/smbrun.c */
|
||||
|
||||
int smbrun(char *cmd,char *outfile,BOOL shared);
|
||||
|
||||
/*The following definitions come from lib/system.c */
|
||||
|
||||
int sys_select(fd_set *fds,struct timeval *tval);
|
||||
@ -308,6 +312,7 @@ char *client_addr(int fd);
|
||||
char *automount_server(char *user_name);
|
||||
char *automount_path(char *user_name);
|
||||
void standard_sub_basic(char *str);
|
||||
void standard_sub(connection_struct *conn,char *str);
|
||||
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
|
||||
int PutUniCode(char *dst,char *src);
|
||||
struct hostent *Get_Hostbyname(char *name);
|
||||
@ -342,6 +347,7 @@ void dump_data(int level,char *buf1,int len);
|
||||
char *tab_depth(int depth);
|
||||
char *sid_to_string(pstring sidstr_out, DOM_SID *sid);
|
||||
BOOL string_to_sid(DOM_SID *sidout, char *sidstr);
|
||||
int str_checksum(char *s);
|
||||
|
||||
/*The following definitions come from libsmb/clientgen.c */
|
||||
|
||||
@ -468,15 +474,21 @@ char *smb_errstr(char *inbuf);
|
||||
|
||||
BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout, int lock_num);
|
||||
void process_blocking_lock_queue(time_t t);
|
||||
BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset, int lock_type);
|
||||
BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int lock_type,
|
||||
BOOL is_locked(int fnum,connection_struct *conn,
|
||||
uint32 count,uint32 offset, int lock_type);
|
||||
BOOL do_lock(int fnum,connection_struct *conn,
|
||||
uint32 count,uint32 offset,int lock_type,
|
||||
int *eclass,uint32 *ecode);
|
||||
BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode);
|
||||
BOOL do_unlock(int fnum,connection_struct *conn,
|
||||
uint32 count,uint32 offset,int *eclass,uint32 *ecode);
|
||||
BOOL locking_init(int read_only);
|
||||
BOOL locking_end(void);
|
||||
BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok);
|
||||
BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token);
|
||||
int get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
|
||||
BOOL lock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int *ptok);
|
||||
BOOL unlock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int token);
|
||||
int get_share_modes(connection_struct *conn,
|
||||
int token, uint32 dev, uint32 inode,
|
||||
share_mode_entry **shares);
|
||||
void del_share_mode(int token, int fnum);
|
||||
BOOL set_share_mode(int token, int fnum, uint16 port, uint16 op_type);
|
||||
@ -1057,6 +1069,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue);
|
||||
BOOL lp_is_default(int snum, struct parm_struct *parm);
|
||||
struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
|
||||
BOOL lp_snum_ok(int iService);
|
||||
void lp_add_one_printer(char *name,char *comment);
|
||||
BOOL lp_loaded(void);
|
||||
void lp_killunused(BOOL (*snumused)(int ));
|
||||
BOOL lp_load(char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc);
|
||||
@ -1819,12 +1832,12 @@ BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data);
|
||||
void reset_chain_pnum(void);
|
||||
void set_chain_pnum(int new_pnum);
|
||||
void init_rpc_pipe_hnd(void);
|
||||
int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid);
|
||||
int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid);
|
||||
int read_pipe(uint16 pnum, char *data, uint32 pos, int n);
|
||||
BOOL get_rpc_pipe(int pnum, pipes_struct **p);
|
||||
char *get_rpc_pipe_hnd_name(int pnum);
|
||||
BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state);
|
||||
BOOL close_rpc_pipe_hnd(int pnum, int cnum);
|
||||
BOOL close_rpc_pipe_hnd(int pnum, connection_struct *conn);
|
||||
int get_rpc_pipe_num(char *buf, int where);
|
||||
|
||||
/*The following definitions come from rpc_server/srv_reg.c */
|
||||
@ -1874,8 +1887,8 @@ BOOL change_oem_password(struct smb_passwd *smbpw, char *new_passwd, BOOL overri
|
||||
|
||||
/*The following definitions come from smbd/connection.c */
|
||||
|
||||
BOOL yield_connection(int cnum,char *name,int max_connections);
|
||||
BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
|
||||
BOOL yield_connection(connection_struct *conn,char *name,int max_connections);
|
||||
BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear);
|
||||
|
||||
/*The following definitions come from smbd/dfree.c */
|
||||
|
||||
@ -1890,17 +1903,17 @@ BOOL dptr_set_wcard(int key, char *wcard);
|
||||
BOOL dptr_set_attr(int key, uint16 attr);
|
||||
uint16 dptr_attr(int key);
|
||||
void dptr_close(int key);
|
||||
void dptr_closecnum(int cnum);
|
||||
void dptr_idlecnum(int cnum);
|
||||
void dptr_closecnum(connection_struct *conn);
|
||||
void dptr_idlecnum(connection_struct *conn);
|
||||
void dptr_closepath(char *path,int pid);
|
||||
int dptr_create(int cnum,char *path, BOOL expect_close,int pid);
|
||||
int dptr_create(connection_struct *conn,char *path, BOOL expect_close,int pid);
|
||||
BOOL dptr_fill(char *buf1,unsigned int key);
|
||||
BOOL dptr_zero(char *buf);
|
||||
void *dptr_fetch(char *buf,int *num);
|
||||
void *dptr_fetch_lanman2(int dptr_num);
|
||||
BOOL dir_check_ftype(int cnum,int mode,struct stat *st,int dirtype);
|
||||
BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend);
|
||||
void *OpenDir(int cnum, char *name, BOOL use_veto);
|
||||
BOOL dir_check_ftype(connection_struct *conn,int mode,struct stat *st,int dirtype);
|
||||
BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend);
|
||||
void *OpenDir(connection_struct *conn, char *name, BOOL use_veto);
|
||||
void CloseDir(void *p);
|
||||
char *ReadDirName(void *p);
|
||||
BOOL SeekDir(void *p,int pos);
|
||||
@ -1917,13 +1930,12 @@ void map_gid_to_sid( gid_t gid, DOM_SID *psid);
|
||||
/*The following definitions come from smbd/ipc.c */
|
||||
|
||||
int get_printerdrivernumber(int snum);
|
||||
int reply_trans(char *inbuf,char *outbuf, int size, int bufsize);
|
||||
int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int bufsize);
|
||||
|
||||
/*The following definitions come from smbd/mangle.c */
|
||||
|
||||
BOOL is_mangled( char *s );
|
||||
BOOL is_8_3( char *fname, BOOL check_case );
|
||||
int str_checksum( char *s );
|
||||
void reset_mangled_cache( void );
|
||||
BOOL check_mangled_cache( char *s );
|
||||
void mangle_name_83( char *s, int s_len );
|
||||
@ -1931,20 +1943,28 @@ BOOL name_map_mangle( char *OutName, BOOL need83, int snum );
|
||||
|
||||
/*The following definitions come from smbd/message.c */
|
||||
|
||||
int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sends(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sendstrt(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sendtxt(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sendend(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
|
||||
/*The following definitions come from smbd/nttrans.c */
|
||||
|
||||
int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_ntcancel(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_nttranss(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_ntcreate_and_X(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_ntcancel(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_nttranss(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
void remove_pending_change_notify_requests_by_fid(int fnum);
|
||||
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);
|
||||
int reply_nttrans(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
|
||||
/*The following definitions come from smbd/password.c */
|
||||
|
||||
@ -1977,9 +1997,10 @@ BOOL domain_client_validate( char *user, char *domain,
|
||||
|
||||
/*The following definitions come from smbd/pipes.c */
|
||||
|
||||
int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_open_pipe_and_X(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_pipe_close(char *inbuf,char *outbuf);
|
||||
int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf);
|
||||
|
||||
/*The following definitions come from smbd/predict.c */
|
||||
|
||||
@ -1995,14 +2016,16 @@ int sysv_printername_ok(char *name);
|
||||
/*The following definitions come from smbd/printing.c */
|
||||
|
||||
void lpq_reset(int snum);
|
||||
void print_file(int fnum);
|
||||
int get_printqueue(int snum,int cnum,print_queue_struct **queue,
|
||||
void print_file(connection_struct *conn, files_struct *file);
|
||||
int get_printqueue(int snum,
|
||||
connection_struct *conn,print_queue_struct **queue,
|
||||
print_status_struct *status);
|
||||
void del_printqueue(int cnum,int snum,int jobid);
|
||||
void status_printjob(int cnum,int snum,int jobid,int status);
|
||||
void del_printqueue(connection_struct *conn,int snum,int jobid);
|
||||
void status_printjob(connection_struct *conn,int snum,int jobid,int status);
|
||||
int printjob_encode(int snum, int job);
|
||||
void printjob_decode(int jobid, int *snum, int *job);
|
||||
void status_printqueue(int cnum,int snum,int status);
|
||||
void status_printqueue(connection_struct *conn,int snum,int status);
|
||||
void load_printers(void);
|
||||
|
||||
/*The following definitions come from smbd/quotas.c */
|
||||
|
||||
@ -2016,81 +2039,95 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
|
||||
/*The following definitions come from smbd/reply.c */
|
||||
|
||||
int reply_special(char *inbuf,char *outbuf);
|
||||
int reply_tcon(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_tcon(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_unknown(char *inbuf,char *outbuf);
|
||||
int reply_ioctl(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_chkpth(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_getatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_setatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_dskattr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_search(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_fclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_open(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_mknew(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_ctemp(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_readbraw(char *inbuf, char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz);
|
||||
int reply_read(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize);
|
||||
int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_lseek(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_unlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_tdis(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_echo(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printopen(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_mkdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_rmdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int rename_internals(char *inbuf, char *outbuf, char *name, char *newname, BOOL replace_if_exists);
|
||||
int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_setdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_setattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_getattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_ioctl(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_ulogoffX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsiz);
|
||||
int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,int dum_buffsize);
|
||||
int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_exit(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_close(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_writeclose(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_lock(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_tdis(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_echo(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printopen(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printclose(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printqueue(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int rename_internals(connection_struct *conn,
|
||||
char *inbuf, char *outbuf, char *name,
|
||||
char *newname, BOOL replace_if_exists);
|
||||
int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
|
||||
|
||||
/*The following definitions come from smbd/server.c */
|
||||
|
||||
void *dflt_sig(void);
|
||||
void killkids(void);
|
||||
mode_t unix_mode(int cnum,int dosmode);
|
||||
int dos_mode(int cnum,char *path,struct stat *sbuf);
|
||||
int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st);
|
||||
int file_utime(int cnum, char *fname, struct utimbuf *times);
|
||||
BOOL set_filetime(int cnum, char *fname, time_t mtime);
|
||||
BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_path);
|
||||
BOOL check_name(char *name,int cnum);
|
||||
void sync_file(int cnum, int fnum);
|
||||
mode_t unix_mode(connection_struct *conn,int dosmode);
|
||||
int dos_mode(connection_struct *conn,char *path,struct stat *sbuf);
|
||||
int dos_chmod(connection_struct *conn,char *fname,int dosmode,struct stat *st);
|
||||
int file_utime(connection_struct *conn, char *fname, struct utimbuf *times);
|
||||
BOOL set_filetime(connection_struct *conn, char *fname, time_t mtime);
|
||||
BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, BOOL *bad_path);
|
||||
BOOL check_name(char *name,connection_struct *conn);
|
||||
void sync_file(connection_struct *conn, int fnum);
|
||||
void close_file(int fnum, BOOL normal_close);
|
||||
void close_directory(int fnum);
|
||||
int open_directory(int fnum,int cnum,char *fname, int smb_ofun, int unixmode, int *action);
|
||||
BOOL check_file_sharing(int cnum,char *fname, BOOL rename_op);
|
||||
int open_directory(int fnum,connection_struct *conn,
|
||||
char *fname, int smb_ofun, int unixmode, int *action);
|
||||
BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op);
|
||||
int check_share_mode( share_mode_entry *share, int deny_mode, char *fname,
|
||||
BOOL fcbopen, int *flags);
|
||||
void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
|
||||
void open_file_shared(int fnum,connection_struct *conn,char *fname,int share_mode,int ofun,
|
||||
int mode,int oplock_request, int *Access,int *action);
|
||||
int seek_file(int fnum,uint32 pos);
|
||||
int read_file(int fnum,char *data,uint32 pos,int n);
|
||||
int write_file(int fnum,char *data,int n);
|
||||
BOOL become_service(int cnum,BOOL do_chdir);
|
||||
BOOL become_service(connection_struct *conn,BOOL do_chdir);
|
||||
int find_service(char *service);
|
||||
int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line);
|
||||
int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line);
|
||||
@ -2101,16 +2138,15 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
|
||||
BOOL receive_next_smb(int smbfd, int oplockfd, char *inbuf, int bufsize, int timeout);
|
||||
BOOL snum_used(int snum);
|
||||
BOOL reload_services(BOOL test);
|
||||
int make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid);
|
||||
connection_struct *make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid, int *ecode);
|
||||
int find_free_file(void );
|
||||
int reply_corep(char *outbuf);
|
||||
int reply_coreplus(char *outbuf);
|
||||
int reply_lanman1(char *outbuf);
|
||||
int reply_lanman2(char *outbuf);
|
||||
int reply_nt1(char *outbuf);
|
||||
void close_cnum(int cnum, uint16 vuid);
|
||||
void close_cnum(connection_struct *conn, uint16 vuid);
|
||||
void exit_server(char *reason);
|
||||
void standard_sub(int cnum,char *str);
|
||||
char *smb_fn_name(int type);
|
||||
int chain_reply(char *inbuf,char *outbuf,int size,int bufsize);
|
||||
void construct_reply_common(char *inbuf,char *outbuf);
|
||||
@ -2128,18 +2164,21 @@ int sslutil_negotiate_ssl(int fd, int msg_type);
|
||||
/*The following definitions come from smbd/trans2.c */
|
||||
|
||||
void mask_convert( char *mask);
|
||||
int reply_findclose(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_findnclose(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_findclose(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_findnclose(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_transs2(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
int reply_trans2(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize);
|
||||
|
||||
/*The following definitions come from smbd/uid.c */
|
||||
|
||||
void init_uid(void);
|
||||
BOOL become_guest(void);
|
||||
BOOL become_user(connection_struct *conn, int cnum, uint16 vuid);
|
||||
BOOL become_user(connection_struct *conn, uint16 vuid);
|
||||
BOOL unbecome_user(void );
|
||||
int smbrun(char *cmd,char *outfile,BOOL shared);
|
||||
void become_root(BOOL save_dir) ;
|
||||
void unbecome_root(BOOL restore_dir);
|
||||
|
||||
|
@ -98,9 +98,20 @@ typedef unsigned short uint16;
|
||||
* the #ifdef directive and will read both definitions, thus creating two
|
||||
* diffferent prototype declarations), so we must do these by hand.
|
||||
*/
|
||||
/* I know the __attribute__ stuff is ugly, but it does ensure we get the
|
||||
arguemnts to DEBUG() right. We have got them wrong too often in the
|
||||
past */
|
||||
#ifdef HAVE_STDARG_H
|
||||
int Debug1( char *, ... );
|
||||
BOOL dbgtext( char *, ... );
|
||||
int Debug1( char *, ... )
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
BOOL dbgtext( char *, ... )
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
#else
|
||||
int Debug1();
|
||||
BOOL dbgtext();
|
||||
@ -451,14 +462,6 @@ struct cli_state {
|
||||
};
|
||||
|
||||
|
||||
struct current_user
|
||||
{
|
||||
int cnum, vuid;
|
||||
int uid, gid;
|
||||
int ngroups;
|
||||
GID_T *groups;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int size;
|
||||
@ -515,32 +518,6 @@ typedef struct
|
||||
time_t status_time;
|
||||
} dir_status_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int cnum;
|
||||
file_fd_struct *fd_ptr;
|
||||
int pos;
|
||||
uint32 size;
|
||||
int mode;
|
||||
int vuid;
|
||||
char *mmap_ptr;
|
||||
uint32 mmap_size;
|
||||
write_bmpx_struct *wbmpx_ptr;
|
||||
struct timeval open_time;
|
||||
BOOL open;
|
||||
BOOL can_lock;
|
||||
BOOL can_read;
|
||||
BOOL can_write;
|
||||
BOOL share_mode;
|
||||
BOOL print_file;
|
||||
BOOL modified;
|
||||
BOOL granted_oplock;
|
||||
BOOL sent_oplock_break;
|
||||
BOOL is_directory;
|
||||
BOOL reserved;
|
||||
char *name;
|
||||
} files_struct;
|
||||
|
||||
struct uid_cache {
|
||||
int entries;
|
||||
int list[UID_CACHE_SIZE];
|
||||
@ -554,39 +531,75 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int service;
|
||||
BOOL force_user;
|
||||
struct uid_cache uid_cache;
|
||||
void *dirptr;
|
||||
BOOL open;
|
||||
BOOL printer;
|
||||
BOOL ipc;
|
||||
BOOL read_only;
|
||||
BOOL admin_user;
|
||||
char *dirpath;
|
||||
char *connectpath;
|
||||
char *origpath;
|
||||
char *user; /* name of user who *opened* this connection */
|
||||
int uid; /* uid of user who *opened* this connection */
|
||||
int gid; /* gid of user who *opened* this connection */
|
||||
unsigned cnum; /* an index passed over the wire */
|
||||
int service;
|
||||
BOOL force_user;
|
||||
struct uid_cache uid_cache;
|
||||
void *dirptr;
|
||||
BOOL open;
|
||||
BOOL printer;
|
||||
BOOL ipc;
|
||||
BOOL read_only;
|
||||
BOOL admin_user;
|
||||
char *dirpath;
|
||||
char *connectpath;
|
||||
char *origpath;
|
||||
char *user; /* name of user who *opened* this connection */
|
||||
int uid; /* uid of user who *opened* this connection */
|
||||
int gid; /* gid of user who *opened* this connection */
|
||||
|
||||
uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
|
||||
uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
|
||||
|
||||
/* following groups stuff added by ih */
|
||||
|
||||
/* This groups info is valid for the user that *opened* the connection */
|
||||
int ngroups;
|
||||
GID_T *groups;
|
||||
|
||||
time_t lastused;
|
||||
BOOL used;
|
||||
int num_files_open;
|
||||
name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
|
||||
name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
|
||||
name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
|
||||
/* following groups stuff added by ih */
|
||||
|
||||
/* This groups info is valid for the user that *opened* the connection */
|
||||
int ngroups;
|
||||
GID_T *groups;
|
||||
|
||||
time_t lastused;
|
||||
BOOL used;
|
||||
int num_files_open;
|
||||
name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
|
||||
name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
|
||||
name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
|
||||
} connection_struct;
|
||||
|
||||
struct current_user
|
||||
{
|
||||
connection_struct *conn;
|
||||
int vuid;
|
||||
int uid, gid;
|
||||
int ngroups;
|
||||
GID_T *groups;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
connection_struct *conn;
|
||||
file_fd_struct *fd_ptr;
|
||||
int pos;
|
||||
uint32 size;
|
||||
int mode;
|
||||
int vuid;
|
||||
char *mmap_ptr;
|
||||
uint32 mmap_size;
|
||||
write_bmpx_struct *wbmpx_ptr;
|
||||
struct timeval open_time;
|
||||
BOOL open;
|
||||
BOOL can_lock;
|
||||
BOOL can_read;
|
||||
BOOL can_write;
|
||||
BOOL share_mode;
|
||||
BOOL print_file;
|
||||
BOOL modified;
|
||||
BOOL granted_oplock;
|
||||
BOOL sent_oplock_break;
|
||||
BOOL is_directory;
|
||||
BOOL reserved;
|
||||
char *fsp_name;
|
||||
} files_struct;
|
||||
|
||||
|
||||
/* Domain controller authentication protocol info */
|
||||
struct dcinfo
|
||||
{
|
||||
@ -679,9 +692,9 @@ typedef struct
|
||||
to support the following operations */
|
||||
struct share_ops {
|
||||
BOOL (*stop_mgmt)(void);
|
||||
BOOL (*lock_entry)(int , uint32 , uint32 , int *);
|
||||
BOOL (*unlock_entry)(int , uint32 , uint32 , int );
|
||||
int (*get_entries)(int , int , uint32 , uint32 , share_mode_entry **);
|
||||
BOOL (*lock_entry)(connection_struct *, uint32 , uint32 , int *);
|
||||
BOOL (*unlock_entry)(connection_struct *, uint32 , uint32 , int );
|
||||
int (*get_entries)(connection_struct *, int , uint32 , uint32 , share_mode_entry **);
|
||||
void (*del_entry)(int , int );
|
||||
BOOL (*set_entry)(int , int , uint16 , uint16 );
|
||||
BOOL (*remove_oplock)(int , int);
|
||||
@ -848,12 +861,12 @@ struct parm_struct
|
||||
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_FNUMS))
|
||||
#define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open && !Files[fnum].is_directory)
|
||||
#define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
|
||||
#define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)
|
||||
#define IS_IPC(cnum) (VALID_CNUM(cnum) && Connections[cnum].ipc)
|
||||
#define IS_PRINT(cnum) (VALID_CNUM(cnum) && Connections[cnum].printer)
|
||||
#define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].cnum)
|
||||
#define OPEN_CNUM(conn) ((conn) && (conn)->open)
|
||||
#define IS_IPC(conn) ((conn) && (conn)->ipc)
|
||||
#define IS_PRINT(conn) ((conn) && (conn)->printer)
|
||||
#define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].conn)
|
||||
|
||||
#define CHECK_FNUM(fnum,c) if (!FNUM_OK(fnum,c)) \
|
||||
#define CHECK_FNUM(fnum,conn) if (!FNUM_OK(fnum,conn)) \
|
||||
return(ERROR(ERRDOS,ERRbadfid))
|
||||
#define CHECK_READ(fnum) if (!Files[fnum].can_read) \
|
||||
return(ERROR(ERRDOS,ERRbadaccess))
|
||||
@ -863,26 +876,25 @@ struct parm_struct
|
||||
return(CACHED_ERROR(fnum))
|
||||
|
||||
/* translates a connection number into a service number */
|
||||
#define SNUM(cnum) (Connections[cnum].service)
|
||||
#define SNUM(conn) ((conn)?(conn)->service:-1)
|
||||
|
||||
/* access various service details */
|
||||
#define SERVICE(snum) (lp_servicename(snum))
|
||||
#define PRINTCAP (lp_printcapname())
|
||||
#define PRINTCOMMAND(snum) (lp_printcommand(snum))
|
||||
#define PRINTERNAME(snum) (lp_printername(snum))
|
||||
#define CAN_WRITE(cnum) (OPEN_CNUM(cnum) && !Connections[cnum].read_only)
|
||||
#define CAN_WRITE(conn) (OPEN_CNUM(conn) && !conn->read_only)
|
||||
#define VALID_SNUM(snum) (lp_snum_ok(snum))
|
||||
#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
|
||||
#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
|
||||
#define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
|
||||
#define CAN_PRINT(cnum) (OPEN_CNUM(cnum) && lp_print_ok(SNUM(cnum)))
|
||||
#define POSTSCRIPT(cnum) (OPEN_CNUM(cnum) && lp_postscript(SNUM(cnum)))
|
||||
#define MAP_HIDDEN(cnum) (OPEN_CNUM(cnum) && lp_map_hidden(SNUM(cnum)))
|
||||
#define MAP_SYSTEM(cnum) (OPEN_CNUM(cnum) && lp_map_system(SNUM(cnum)))
|
||||
#define MAP_ARCHIVE(cnum) (OPEN_CNUM(cnum) && lp_map_archive(SNUM(cnum)))
|
||||
#define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list))
|
||||
#define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list))
|
||||
#define IS_VETO_OPLOCK_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_oplock_list))
|
||||
#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service))
|
||||
#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service))
|
||||
#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service))
|
||||
#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service))
|
||||
#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list))
|
||||
#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list))
|
||||
#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list))
|
||||
|
||||
#define SMBENCRYPT() (lp_encrypted_passwords())
|
||||
|
||||
@ -1228,7 +1240,11 @@ struct parm_struct
|
||||
#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
int slprintf(char *str, int n, char *format, ...);
|
||||
int slprintf(char *str, int n, char *format, ...)
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 3, 4)))
|
||||
#endif
|
||||
;
|
||||
#else
|
||||
int slprintf();
|
||||
#endif
|
||||
|
173
source3/lib/smbrun.c
Normal file
173
source3/lib/smbrun.c
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
run a command as a specified user
|
||||
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"
|
||||
|
||||
/* need to move this from here!! need some sleep ... */
|
||||
struct current_user current_user;
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/****************************************************************************
|
||||
This is a utility function of smbrun(). It must be called only from
|
||||
the child as it may leave the caller in a privilaged state.
|
||||
****************************************************************************/
|
||||
static BOOL setup_stdout_file(char *outfile,BOOL shared)
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
mode_t mode = S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH;
|
||||
int flags = O_RDWR|O_CREAT|O_TRUNC|O_EXCL;
|
||||
|
||||
close(1);
|
||||
|
||||
if (shared) {
|
||||
/* become root - unprivilaged users can't delete these files */
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresgid(0,0,0);
|
||||
setresuid(0,0,0);
|
||||
#else
|
||||
setuid(0);
|
||||
seteuid(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(stat(outfile, &st) == 0) {
|
||||
/* Check we're not deleting a device file. */
|
||||
if(st.st_mode & S_IFREG)
|
||||
unlink(outfile);
|
||||
else
|
||||
flags = O_RDWR;
|
||||
}
|
||||
/* now create the file */
|
||||
fd = open(outfile,flags,mode);
|
||||
|
||||
if (fd == -1) return False;
|
||||
|
||||
if (fd != 1) {
|
||||
if (dup2(fd,1) != 0) {
|
||||
DEBUG(2,("Failed to create stdout file descriptor\n"));
|
||||
close(fd);
|
||||
return False;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
run a command being careful about uid/gid handling and putting the output in
|
||||
outfile (or discard it if outfile is NULL).
|
||||
|
||||
if shared is True then ensure the file will be writeable by all users
|
||||
but created such that its owned by root. This overcomes a security hole.
|
||||
|
||||
if shared is not set then open the file with O_EXCL set
|
||||
****************************************************************************/
|
||||
int smbrun(char *cmd,char *outfile,BOOL shared)
|
||||
{
|
||||
extern struct current_user current_user;
|
||||
int fd,pid;
|
||||
int uid = current_user.uid;
|
||||
int gid = current_user.gid;
|
||||
|
||||
#ifndef HAVE_EXECL
|
||||
int ret;
|
||||
pstring syscmd;
|
||||
char *path = lp_smbrun();
|
||||
|
||||
/* in the old method we use system() to execute smbrun which then
|
||||
executes the command (using system() again!). This involves lots
|
||||
of shell launches and is very slow. It also suffers from a
|
||||
potential security hole */
|
||||
if (!file_exist(path,NULL)) {
|
||||
DEBUG(0,("SMBRUN ERROR: Can't find %s. Installation problem?\n",path));
|
||||
return(1);
|
||||
}
|
||||
|
||||
slprintf(syscmd,sizeof(syscmd)-1,"%s %d %d \"(%s 2>&1) > %s\"",
|
||||
path,uid,gid,cmd,
|
||||
outfile?outfile:"/dev/null");
|
||||
|
||||
DEBUG(5,("smbrun - running %s ",syscmd));
|
||||
ret = system(syscmd);
|
||||
DEBUG(5,("gave %d\n",ret));
|
||||
return(ret);
|
||||
#else
|
||||
/* in this newer method we will exec /bin/sh with the correct
|
||||
arguments, after first setting stdout to point at the file */
|
||||
|
||||
if ((pid=fork())) {
|
||||
int status=0;
|
||||
/* the parent just waits for the child to exit */
|
||||
if (sys_waitpid(pid,&status,0) != pid) {
|
||||
DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
|
||||
return -1;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* we are in the child. we exec /bin/sh to do the work for us. we
|
||||
don't directly exec the command we want because it may be a
|
||||
pipeline or anything else the config file specifies */
|
||||
|
||||
/* point our stdout at the file we want output to go into */
|
||||
if (outfile && !setup_stdout_file(outfile,shared)) {
|
||||
exit(80);
|
||||
}
|
||||
|
||||
/* now completely lose our privilages. This is a fairly paranoid
|
||||
way of doing it, but it does work on all systems that I know of */
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresgid(0,0,0);
|
||||
setresuid(0,0,0);
|
||||
setresgid(gid,gid,gid);
|
||||
setresuid(uid,uid,uid);
|
||||
#else
|
||||
setuid(0);
|
||||
seteuid(0);
|
||||
setgid(gid);
|
||||
setegid(gid);
|
||||
setuid(uid);
|
||||
seteuid(uid);
|
||||
#endif
|
||||
|
||||
if (getuid() != uid || geteuid() != uid ||
|
||||
getgid() != gid || getegid() != gid) {
|
||||
/* we failed to lose our privilages - do not execute
|
||||
the command */
|
||||
exit(81); /* we can't print stuff at this stage,
|
||||
instead use exit codes for debugging */
|
||||
}
|
||||
|
||||
/* close all other file descriptors, leaving only 0, 1 and 2. 0 and
|
||||
2 point to /dev/null from the startup code */
|
||||
for (fd=3;fd<256;fd++) close(fd);
|
||||
|
||||
execl("/bin/sh","sh","-c",cmd,NULL);
|
||||
|
||||
/* not reached */
|
||||
exit(82);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
@ -129,7 +129,7 @@ a simple opendir() wrapper
|
||||
********************************************************************/
|
||||
DIR *sys_opendir(char *dname)
|
||||
{
|
||||
return(opendir(dos_to_unix(dname,False)));
|
||||
return(opendir(dos_to_unix(dname,False)));
|
||||
}
|
||||
|
||||
|
||||
@ -342,15 +342,15 @@ for getwd
|
||||
********************************************************************/
|
||||
char *sys_getwd(char *s)
|
||||
{
|
||||
char *wd;
|
||||
char *wd;
|
||||
#ifdef HAVE_GETCWD
|
||||
wd = (char *)getcwd(s, sizeof (pstring));
|
||||
wd = (char *)getcwd(s, sizeof (pstring));
|
||||
#else
|
||||
wd = (char *)getwd(s);
|
||||
wd = (char *)getwd(s);
|
||||
#endif
|
||||
if (wd)
|
||||
unix_to_dos (wd, True);
|
||||
return wd;
|
||||
if (wd)
|
||||
unix_to_dos(wd, True);
|
||||
return wd;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
@ -2752,7 +2752,7 @@ static BOOL unix_do_match(char *str, char *regexp, int case_sig)
|
||||
while(*str) {
|
||||
while(*str && (case_sig ? (*p != *str) : (toupper(*p)!=toupper(*str))))
|
||||
str++;
|
||||
if(do_match(str,p,case_sig))
|
||||
if(unix_do_match(str,p,case_sig))
|
||||
return True;
|
||||
if(!*str)
|
||||
return False;
|
||||
@ -2846,8 +2846,8 @@ static BOOL unix_mask_match(char *str, char *regexp, int case_sig,BOOL trans2)
|
||||
}
|
||||
}
|
||||
|
||||
matched = do_match(sbase,ebase,case_sig) &&
|
||||
(trans2 || do_match(sext,eext,case_sig));
|
||||
matched = unix_do_match(sbase,ebase,case_sig) &&
|
||||
(trans2 || unix_do_match(sext,eext,case_sig));
|
||||
|
||||
DEBUG(8,("unix_mask_match returning %d\n", matched));
|
||||
|
||||
@ -4134,6 +4134,67 @@ void standard_sub_basic(char *str)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do some standard substitutions in a string
|
||||
****************************************************************************/
|
||||
void standard_sub(connection_struct *conn,char *str)
|
||||
{
|
||||
char *p, *s, *home;
|
||||
|
||||
for (s=str; (p=strchr(s, '%'));s=p) {
|
||||
switch (*(p+1)) {
|
||||
case 'H':
|
||||
if ((home = get_home_dir(conn->user))) {
|
||||
string_sub(p,"%H",home);
|
||||
} else {
|
||||
p += 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
string_sub(p,"%P",conn->connectpath);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
string_sub(p,"%S",
|
||||
lp_servicename(SNUM(conn)));
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
string_sub(p,"%g",
|
||||
gidtoname(conn->gid));
|
||||
break;
|
||||
case 'u':
|
||||
string_sub(p,"%u",conn->user);
|
||||
break;
|
||||
|
||||
/* Patch from jkf@soton.ac.uk Left the %N (NIS
|
||||
* server name) in standard_sub_basic as it is
|
||||
* a feature for logon servers, hence uses the
|
||||
* username. The %p (NIS server path) code is
|
||||
* here as it is used instead of the default
|
||||
* "path =" string in [homes] and so needs the
|
||||
* service name, not the username. */
|
||||
case 'p':
|
||||
string_sub(p,"%p",
|
||||
automount_path(lp_servicename(SNUM(conn))));
|
||||
break;
|
||||
case '\0':
|
||||
p++;
|
||||
break; /* don't run off the end of the string
|
||||
*/
|
||||
|
||||
default: p+=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
standard_sub_basic(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
are two IPs on the same subnet?
|
||||
********************************************************************/
|
||||
@ -5064,3 +5125,28 @@ BOOL string_to_sid(DOM_SID *sidout, char *sidstr)
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Provide a checksum on a string
|
||||
*
|
||||
* Input: s - the nul-terminated character string for which the checksum
|
||||
* will be calculated.
|
||||
*
|
||||
* Output: The checksum value calculated for s.
|
||||
*
|
||||
* ****************************************************************************
|
||||
*/
|
||||
int str_checksum(char *s)
|
||||
{
|
||||
int res = 0;
|
||||
int c;
|
||||
int i=0;
|
||||
|
||||
while(*s) {
|
||||
c = *s;
|
||||
res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
|
||||
s++;
|
||||
i++;
|
||||
}
|
||||
return(res);
|
||||
} /* str_checksum */
|
||||
|
@ -96,7 +96,7 @@ void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp,
|
||||
|
||||
DEBUG(5,(" sess_key : %s\n", credstr(session_key)));
|
||||
DEBUG(5,(" stor_cred: %s\n", credstr(stor_cred->data)));
|
||||
DEBUG(5,(" timestamp: %lx\n" , timestamp.time));
|
||||
DEBUG(5,(" timestamp: %x\n" , timestamp.time));
|
||||
DEBUG(5,(" timecred : %s\n", credstr(time_cred.data)));
|
||||
DEBUG(5,(" calc_cred: %s\n", credstr(cred->data)));
|
||||
}
|
||||
@ -200,12 +200,12 @@ BOOL deal_with_creds(uchar sess_key[8],
|
||||
new_cred = IVAL(sto_clnt_cred->challenge.data, 0);
|
||||
new_cred += new_clnt_time.time;
|
||||
|
||||
DEBUG(5,("deal_with_creds: new_cred[0]=%lx\n", new_cred));
|
||||
DEBUG(5,("deal_with_creds: new_cred[0]=%x\n", new_cred));
|
||||
|
||||
/* doesn't matter that server time is 0 */
|
||||
rtn_srv_cred->timestamp.time = 0;
|
||||
|
||||
DEBUG(5,("deal_with_creds: new_clnt_time=%lx\n", new_clnt_time.time));
|
||||
DEBUG(5,("deal_with_creds: new_clnt_time=%x\n", new_clnt_time.time));
|
||||
|
||||
/* create return credentials for inclusion in the reply */
|
||||
cred_create(sess_key, &(sto_clnt_cred->challenge), new_clnt_time,
|
||||
|
@ -90,7 +90,7 @@ static void debug_nmb_res_rec(struct res_rec *res, char *hdr)
|
||||
DEBUGADD(4, ("%c", x));
|
||||
}
|
||||
|
||||
DEBUGADD(4, (" hex ", i));
|
||||
DEBUGADD(4, (" hex "));
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include "includes.h"
|
||||
extern int DEBUGLEVEL;
|
||||
extern connection_struct Connections[];
|
||||
extern files_struct Files[];
|
||||
extern int Client;
|
||||
|
||||
@ -147,13 +146,10 @@ static void blocking_lock_reply_error(blocking_lock_record *blr, int eclass, int
|
||||
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
|
||||
uint16 num_locks = SVAL(inbuf,smb_vwv7);
|
||||
uint32 count, offset;
|
||||
int cnum;
|
||||
int lock_num = blr->lock_num;
|
||||
char *data;
|
||||
int i;
|
||||
|
||||
cnum = SVAL(inbuf,smb_tid);
|
||||
|
||||
data = smb_buf(inbuf) + 10*num_ulocks;
|
||||
|
||||
/*
|
||||
@ -164,7 +160,7 @@ static void blocking_lock_reply_error(blocking_lock_record *blr, int eclass, int
|
||||
for(i = blr->lock_num; i >= 0; i--) {
|
||||
count = IVAL(data,SMB_LKLEN_OFFSET(i));
|
||||
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
|
||||
do_unlock(fnum,cnum,count,offset,&dummy1,&dummy2);
|
||||
do_unlock(fnum,conn,count,offset,&dummy1,&dummy2);
|
||||
}
|
||||
|
||||
construct_reply_common(inbuf, outbuf);
|
||||
@ -185,14 +181,11 @@ static BOOL blocking_lock_record_process(blocking_lock_record *blr)
|
||||
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
|
||||
uint16 num_locks = SVAL(inbuf,smb_vwv7);
|
||||
uint32 count, offset;
|
||||
int cnum;
|
||||
int lock_num = blr->lock_num;
|
||||
char *data;
|
||||
int eclass=0;
|
||||
uint32 ecode=0;
|
||||
|
||||
cnum = SVAL(inbuf,smb_tid);
|
||||
|
||||
data = smb_buf(inbuf) + 10*num_ulocks;
|
||||
|
||||
/*
|
||||
@ -203,7 +196,7 @@ static BOOL blocking_lock_record_process(blocking_lock_record *blr)
|
||||
for(; blr->lock_num < num_locks; blr->lock_num++) {
|
||||
count = IVAL(data,SMB_LKLEN_OFFSET(blr->lock_num));
|
||||
offset = IVAL(data,SMB_LKOFF_OFFSET(blr->lock_num));
|
||||
if(!do_lock(fnum,cnum,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
|
||||
if(!do_lock(fnum,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
|
||||
&eclass, &ecode))
|
||||
break;
|
||||
}
|
||||
@ -214,8 +207,8 @@ static BOOL blocking_lock_record_process(blocking_lock_record *blr)
|
||||
* Success - we got all the locks.
|
||||
*/
|
||||
|
||||
DEBUG(3,("blocking_lock_record_process fnum=%d cnum=%d type=%d num_locks=%d\n",
|
||||
fnum, cnum, (unsigned int)locktype, num_locks) );
|
||||
DEBUG(3,("blocking_lock_record_process fnum=%d type=%d num_locks=%d\n",
|
||||
fnum, (unsigned int)locktype, num_locks) );
|
||||
|
||||
blocking_lock_reply_success(blr);
|
||||
return True;
|
||||
@ -260,7 +253,6 @@ void process_blocking_lock_queue(time_t t)
|
||||
|
||||
while(blr != NULL) {
|
||||
int fnum = GETFNUM(blr->inbuf,smb_vwv2);
|
||||
int cnum = SVAL(blr->inbuf,smb_tid);
|
||||
files_struct *fsp = &Files[fnum];
|
||||
uint16 vuid = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID :
|
||||
SVAL(blr->inbuf,smb_uid);
|
||||
@ -282,7 +274,7 @@ void process_blocking_lock_queue(time_t t)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!become_user(&Connections[cnum],cnum,vuid)) {
|
||||
if(!become_user(conn,vuid)) {
|
||||
DEBUG(0,("process_blocking_lock_queue: Unable to become user vuid=%d.\n",
|
||||
vuid ));
|
||||
/*
|
||||
@ -294,9 +286,8 @@ void process_blocking_lock_queue(time_t t)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!become_service(cnum,True)) {
|
||||
DEBUG(0,("process_blocking_lock_queue: Unable to become service cnum=%d. \
|
||||
Error was %s.\n", cnum, strerror(errno) ));
|
||||
if(!become_service(conn,True)) {
|
||||
DEBUG(0,("process_blocking_lock_queue: Unable to become service Error was %s.\n", strerror(errno) ));
|
||||
/*
|
||||
* Remove the entry and return an error to the client.
|
||||
*/
|
||||
@ -365,39 +356,39 @@ static int map_lock_type( files_struct *fsp, int lock_type)
|
||||
/****************************************************************************
|
||||
Utility function called to see if a file region is locked.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset, int lock_type)
|
||||
BOOL is_locked(int fnum,connection_struct *conn,
|
||||
uint32 count,uint32 offset, int lock_type)
|
||||
{
|
||||
int snum = SNUM(cnum);
|
||||
files_struct *fsp = &Files[fnum];
|
||||
int snum = SNUM(conn);
|
||||
files_struct *fsp = &Files[fnum];
|
||||
|
||||
if (count == 0)
|
||||
return(False);
|
||||
if (count == 0)
|
||||
return(False);
|
||||
|
||||
if (!lp_locking(snum) || !lp_strict_locking(snum))
|
||||
return(False);
|
||||
if (!lp_locking(snum) || !lp_strict_locking(snum))
|
||||
return(False);
|
||||
|
||||
/*
|
||||
* Note that most UNIX's can *test* for a write lock on
|
||||
* a read-only fd, just not *set* a write lock on a read-only
|
||||
* fd. So we don't need to use map_lock_type here.
|
||||
*/
|
||||
|
||||
return(fcntl_lock(fsp->fd_ptr->fd,F_GETLK,offset,count,lock_type));
|
||||
/*
|
||||
* Note that most UNIX's can *test* for a write lock on
|
||||
* a read-only fd, just not *set* a write lock on a read-only
|
||||
* fd. So we don't need to use map_lock_type here.
|
||||
*/
|
||||
|
||||
return(fcntl_lock(fsp->fd_ptr->fd,F_GETLK,offset,count,lock_type));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
Utility function called by locking requests.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int lock_type,
|
||||
BOOL do_lock(int fnum,connection_struct *conn,
|
||||
uint32 count,uint32 offset,int lock_type,
|
||||
int *eclass,uint32 *ecode)
|
||||
{
|
||||
BOOL ok = False;
|
||||
files_struct *fsp = &Files[fnum];
|
||||
|
||||
if (!lp_locking(SNUM(cnum)))
|
||||
if (!lp_locking(SNUM(conn)))
|
||||
return(True);
|
||||
|
||||
if (count == 0) {
|
||||
@ -406,7 +397,7 @@ BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int lock_type,
|
||||
return False;
|
||||
}
|
||||
|
||||
if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->cnum == cnum))
|
||||
if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->conn == conn))
|
||||
ok = fcntl_lock(fsp->fd_ptr->fd,F_SETLK,offset,count,
|
||||
map_lock_type(fsp,lock_type));
|
||||
|
||||
@ -422,16 +413,16 @@ BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int lock_type,
|
||||
/****************************************************************************
|
||||
Utility function called by unlocking requests.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode)
|
||||
BOOL do_unlock(int fnum,connection_struct *conn,
|
||||
uint32 count,uint32 offset,int *eclass,uint32 *ecode)
|
||||
{
|
||||
BOOL ok = False;
|
||||
files_struct *fsp = &Files[fnum];
|
||||
|
||||
if (!lp_locking(SNUM(cnum)))
|
||||
if (!lp_locking(SNUM(conn)))
|
||||
return(True);
|
||||
|
||||
if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->cnum == cnum))
|
||||
if (OPEN_FNUM(fnum) && fsp->can_lock && (fsp->conn == conn))
|
||||
ok = fcntl_lock(fsp->fd_ptr->fd,F_SETLK,offset,count,F_UNLCK);
|
||||
|
||||
if (!ok) {
|
||||
@ -481,29 +472,29 @@ BOOL locking_end(void)
|
||||
/*******************************************************************
|
||||
Lock a hash bucket entry.
|
||||
******************************************************************/
|
||||
|
||||
BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
|
||||
BOOL lock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int *ptok)
|
||||
{
|
||||
return share_ops->lock_entry(cnum, dev, inode, ptok);
|
||||
return share_ops->lock_entry(conn, dev, inode, ptok);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Unlock a hash bucket entry.
|
||||
******************************************************************/
|
||||
|
||||
BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
|
||||
BOOL unlock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int token)
|
||||
{
|
||||
return share_ops->unlock_entry(cnum, dev, inode, token);
|
||||
return share_ops->unlock_entry(conn, dev, inode, token);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Get all share mode entries for a dev/inode pair.
|
||||
********************************************************************/
|
||||
|
||||
int get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
|
||||
int get_share_modes(connection_struct *conn,
|
||||
int token, uint32 dev, uint32 inode,
|
||||
share_mode_entry **shares)
|
||||
{
|
||||
return share_ops->get_entries(cnum, token, dev, inode, shares);
|
||||
return share_ops->get_entries(conn, token, dev, inode, shares);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
@ -37,7 +37,6 @@
|
||||
#ifdef FAST_SHARE_MODES
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern connection_struct Connections[];
|
||||
extern files_struct Files[];
|
||||
|
||||
static struct shmem_ops *shmops;
|
||||
@ -79,15 +78,17 @@ static BOOL shm_stop_share_mode_mgmt(void)
|
||||
/*******************************************************************
|
||||
lock a hash bucket entry in shared memory for share_mode management
|
||||
******************************************************************/
|
||||
static BOOL shm_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
|
||||
static BOOL shm_lock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int *ptok)
|
||||
{
|
||||
return shmops->lock_hash_entry(HASH_ENTRY(dev, inode));
|
||||
return shmops->lock_hash_entry(HASH_ENTRY(dev, inode));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
unlock a hash bucket entry in shared memory for share_mode management
|
||||
******************************************************************/
|
||||
static BOOL shm_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
|
||||
static BOOL shm_unlock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int token)
|
||||
{
|
||||
return shmops->unlock_hash_entry(HASH_ENTRY(dev, inode));
|
||||
}
|
||||
@ -95,7 +96,8 @@ static BOOL shm_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token
|
||||
/*******************************************************************
|
||||
get all share mode entries in shared memory for a dev/inode pair.
|
||||
********************************************************************/
|
||||
static int shm_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
|
||||
static int shm_get_share_modes(connection_struct *conn,
|
||||
int token, uint32 dev, uint32 inode,
|
||||
share_mode_entry **old_shares)
|
||||
{
|
||||
int *mode_array;
|
||||
@ -426,7 +428,7 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
|
||||
/* We must create a share_mode_record */
|
||||
share_mode_record *new_mode_p = NULL;
|
||||
int new_offset = shmops->shm_alloc(sizeof(share_mode_record) +
|
||||
strlen(fs_p->name) + 1);
|
||||
strlen(fs_p->fsp_name) + 1);
|
||||
if(new_offset == 0) {
|
||||
DEBUG(0,("ERROR:set_share_mode shmops->shm_alloc fail!\n"));
|
||||
return False;
|
||||
@ -437,7 +439,7 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
|
||||
new_mode_p->st_ino = inode;
|
||||
new_mode_p->num_share_mode_entries = 0;
|
||||
new_mode_p->share_mode_entries = 0;
|
||||
pstrcpy(new_mode_p->file_name, fs_p->name);
|
||||
pstrcpy(new_mode_p->file_name, fs_p->fsp_name);
|
||||
|
||||
/* Chain onto the start of the hash chain (in the hope we will be used first). */
|
||||
new_mode_p->next_offset = mode_array[hash_entry];
|
||||
@ -446,7 +448,7 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
|
||||
file_scanner_p = new_mode_p;
|
||||
|
||||
DEBUG(3,("set_share_mode: Created share record for %s (dev %d inode %d)\n",
|
||||
fs_p->name, dev, inode));
|
||||
fs_p->fsp_name, dev, inode));
|
||||
}
|
||||
|
||||
/* Now create the share mode entry */
|
||||
@ -485,7 +487,7 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
|
||||
file_scanner_p->num_share_mode_entries += 1;
|
||||
|
||||
DEBUG(3,("set_share_mode: Created share entry for %s with mode 0x%X pid=%d\n",
|
||||
fs_p->name, fs_p->share_mode, new_entry_p->e.pid));
|
||||
fs_p->fsp_name, fs_p->share_mode, new_entry_p->e.pid));
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
@ -37,7 +37,6 @@
|
||||
#ifndef FAST_SHARE_MODES
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern connection_struct Connections[];
|
||||
extern files_struct Files[];
|
||||
|
||||
/*
|
||||
@ -82,23 +81,24 @@ static BOOL slow_stop_share_mode_mgmt(void)
|
||||
/*******************************************************************
|
||||
name a share file
|
||||
******************************************************************/
|
||||
static BOOL share_name(int cnum, uint32 dev, uint32 inode, char *name)
|
||||
static BOOL share_name(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, char *name)
|
||||
{
|
||||
int len;
|
||||
pstrcpy(name,lp_lockdir());
|
||||
trim_string(name,"","/");
|
||||
if (!*name) return(False);
|
||||
len = strlen(name);
|
||||
name += len;
|
||||
|
||||
slprintf(name, sizeof(pstring) - len - 1, "/share.%u.%u",dev,inode);
|
||||
return(True);
|
||||
int len;
|
||||
pstrcpy(name,lp_lockdir());
|
||||
trim_string(name,"","/");
|
||||
if (!*name) return(False);
|
||||
len = strlen(name);
|
||||
name += len;
|
||||
|
||||
slprintf(name, sizeof(pstring) - len - 1, "/share.%u.%u",dev,inode);
|
||||
return(True);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Force a share file to be deleted.
|
||||
********************************************************************/
|
||||
static int delete_share_file( int cnum, char *fname )
|
||||
static int delete_share_file(connection_struct *conn, char *fname )
|
||||
{
|
||||
if (read_only) return -1;
|
||||
|
||||
@ -124,7 +124,8 @@ static int delete_share_file( int cnum, char *fname )
|
||||
/*******************************************************************
|
||||
lock a share mode file.
|
||||
******************************************************************/
|
||||
static BOOL slow_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
|
||||
static BOOL slow_lock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int *ptok)
|
||||
{
|
||||
pstring fname;
|
||||
int fd;
|
||||
@ -132,7 +133,7 @@ static BOOL slow_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
|
||||
|
||||
*ptok = (int)-1;
|
||||
|
||||
if(!share_name(cnum, dev, inode, fname))
|
||||
if(!share_name(conn, dev, inode, fname))
|
||||
return False;
|
||||
|
||||
if (read_only) return True;
|
||||
@ -216,7 +217,8 @@ static BOOL slow_lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok)
|
||||
/*******************************************************************
|
||||
unlock a share mode file.
|
||||
******************************************************************/
|
||||
static BOOL slow_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token)
|
||||
static BOOL slow_unlock_share_entry(connection_struct *conn,
|
||||
uint32 dev, uint32 inode, int token)
|
||||
{
|
||||
int fd = (int)token;
|
||||
int ret = True;
|
||||
@ -228,7 +230,7 @@ static BOOL slow_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int toke
|
||||
/* Fix for zero length share files from
|
||||
Gerald Werner <wernerg@mfldclin.edu> */
|
||||
|
||||
share_name(cnum, dev, inode, fname);
|
||||
share_name(conn, dev, inode, fname);
|
||||
|
||||
/* get the share mode file size */
|
||||
if(fstat((int)token, &sb) != 0)
|
||||
@ -246,7 +248,7 @@ static BOOL slow_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int toke
|
||||
|
||||
/* remove the share file if zero length */
|
||||
if(sb.st_size == 0)
|
||||
delete_share_file(cnum, fname);
|
||||
delete_share_file(conn, fname);
|
||||
|
||||
/* token is the fd of the open share mode file. */
|
||||
/* Unlock the first byte. */
|
||||
@ -264,7 +266,7 @@ static BOOL slow_unlock_share_entry(int cnum, uint32 dev, uint32 inode, int toke
|
||||
/*******************************************************************
|
||||
Read a share file into a buffer.
|
||||
********************************************************************/
|
||||
static int read_share_file(int cnum, int fd, char *fname, char **out, BOOL *p_new_file)
|
||||
static int read_share_file(connection_struct *conn, int fd, char *fname, char **out, BOOL *p_new_file)
|
||||
{
|
||||
struct stat sb;
|
||||
char *buf;
|
||||
@ -317,7 +319,7 @@ locking version (was %d, should be %d).\n",fname,
|
||||
IVAL(buf,SMF_VERSION_OFFSET), LOCKING_VERSION));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(cnum, fname);
|
||||
delete_share_file(conn, fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -335,7 +337,7 @@ locking version (was %d, should be %d).\n",fname,
|
||||
deleting it.\n", fname));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(cnum, fname);
|
||||
delete_share_file(conn, fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -346,7 +348,7 @@ deleting it.\n", fname));
|
||||
/*******************************************************************
|
||||
get all share mode entries in a share file for a dev/inode pair.
|
||||
********************************************************************/
|
||||
static int slow_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
|
||||
static int slow_get_share_modes(connection_struct *conn, int token, uint32 dev, uint32 inode,
|
||||
share_mode_entry **old_shares)
|
||||
{
|
||||
int fd = (int)token;
|
||||
@ -377,9 +379,9 @@ static int slow_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
|
||||
16 - oplock port (if oplocks in use) - 2 bytes.
|
||||
*/
|
||||
|
||||
share_name(cnum, dev, inode, fname);
|
||||
share_name(conn, dev, inode, fname);
|
||||
|
||||
if(read_share_file( cnum, fd, fname, &buf, &new_file) != 0)
|
||||
if(read_share_file( conn, fd, fname, &buf, &new_file) != 0)
|
||||
{
|
||||
DEBUG(0,("ERROR: get_share_modes: Failed to read share file %s\n",
|
||||
fname));
|
||||
@ -419,7 +421,7 @@ for share file %d\n", num_entries, fname));
|
||||
fname));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(cnum, fname);
|
||||
delete_share_file(conn, fname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -460,7 +462,7 @@ it left a share mode entry with mode 0x%X in share file %s\n",
|
||||
*old_shares = 0;
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(cnum, fname);
|
||||
delete_share_file(conn, fname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -546,10 +548,10 @@ static void slow_del_share_mode(int token, int fnum)
|
||||
BOOL deleted = False;
|
||||
BOOL new_file;
|
||||
|
||||
share_name(fs_p->cnum, fs_p->fd_ptr->dev,
|
||||
share_name(fs_p->conn, fs_p->fd_ptr->dev,
|
||||
fs_p->fd_ptr->inode, fname);
|
||||
|
||||
if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
|
||||
if(read_share_file( fs_p->conn, fd, fname, &buf, &new_file) != 0)
|
||||
{
|
||||
DEBUG(0,("ERROR: del_share_mode: Failed to read share file %s\n",
|
||||
fname));
|
||||
@ -560,7 +562,7 @@ static void slow_del_share_mode(int token, int fnum)
|
||||
{
|
||||
DEBUG(0,("ERROR:del_share_mode: share file %s is new (size zero), deleting it.\n",
|
||||
fname));
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -584,7 +586,7 @@ for share file %d\n", num_entries, fname));
|
||||
fname));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -635,7 +637,7 @@ for share file %d\n", num_entries, fname));
|
||||
fname));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(fs_p->cnum,fname);
|
||||
delete_share_file(fs_p->conn,fname);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -685,7 +687,7 @@ static BOOL slow_set_share_mode(int token,int fnum, uint16 port, uint16 op_type)
|
||||
int header_size;
|
||||
char *p;
|
||||
|
||||
share_name(fs_p->cnum, fs_p->fd_ptr->dev,
|
||||
share_name(fs_p->conn, fs_p->fd_ptr->dev,
|
||||
fs_p->fd_ptr->inode, fname);
|
||||
|
||||
if(fstat(fd, &sb) != 0)
|
||||
@ -733,7 +735,7 @@ locking version (was %d, should be %d).\n",fname, IVAL(buf,SMF_VERSION_OFFSET),
|
||||
LOCKING_VERSION));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -746,7 +748,7 @@ locking version (was %d, should be %d).\n",fname, IVAL(buf,SMF_VERSION_OFFSET),
|
||||
deleting it.\n", fname));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -794,7 +796,7 @@ deleting it.\n", fname));
|
||||
{
|
||||
DEBUG(2,("ERROR: set_share_mode: Failed to write share file %s - \
|
||||
deleting it (%s).\n",fname, strerror(errno)));
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
if(buf)
|
||||
free(buf);
|
||||
return False;
|
||||
@ -838,10 +840,10 @@ static BOOL slow_remove_share_oplock(int fnum, int token)
|
||||
BOOL found = False;
|
||||
BOOL new_file;
|
||||
|
||||
share_name(fs_p->cnum, fs_p->fd_ptr->dev,
|
||||
share_name(fs_p->conn, fs_p->fd_ptr->dev,
|
||||
fs_p->fd_ptr->inode, fname);
|
||||
|
||||
if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
|
||||
if(read_share_file( fs_p->conn, fd, fname, &buf, &new_file) != 0)
|
||||
{
|
||||
DEBUG(0,("ERROR: remove_share_oplock: Failed to read share file %s\n",
|
||||
fname));
|
||||
@ -852,7 +854,7 @@ static BOOL slow_remove_share_oplock(int fnum, int token)
|
||||
{
|
||||
DEBUG(0,("ERROR: remove_share_oplock: share file %s is new (size zero), \
|
||||
deleting it.\n", fname));
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -876,7 +878,7 @@ for share file %d\n", num_entries, fname));
|
||||
fname));
|
||||
if(buf)
|
||||
free(buf);
|
||||
delete_share_file(fs_p->cnum, fname);
|
||||
delete_share_file(fs_p->conn, fname);
|
||||
return False;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ static BOOL smb_shm_global_unlock(void)
|
||||
|
||||
if(smb_shm_times_locked == 0)
|
||||
{
|
||||
DEBUG(0,("ERROR smb_shm_global_unlock : shmem not locked\n",smb_shm_fd));
|
||||
DEBUG(0,("ERROR smb_shm_global_unlock : shmem not locked\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,8 @@ static BOOL dump_core(void)
|
||||
#endif
|
||||
|
||||
|
||||
DEBUG( 0, ( "Dumping core in %s\n",dname ) );
|
||||
DEBUG(0,("Dumping core in %s\n",dname));
|
||||
abort();
|
||||
return( True );
|
||||
} /* dump_core */
|
||||
#endif
|
||||
|
@ -124,7 +124,7 @@ struct browse_cache_record *create_browser_in_lmb_cache( char *work_name,
|
||||
Debug1( "nmbd_browserdb:create_browser_in_lmb_cache()\n" );
|
||||
Debug1( " Added lmb cache entry for workgroup %s ", browc->work_group );
|
||||
Debug1( "name %s IP %s ", browc->lmb_name, inet_ntoa(ip) );
|
||||
Debug1( "ttl %d\n", browc->death_time );
|
||||
Debug1( "ttl %d\n", (int)browc->death_time );
|
||||
}
|
||||
|
||||
return( browc );
|
||||
|
@ -207,7 +207,7 @@ responding.\n", inet_ntoa(rrec->packet->ip)));
|
||||
rrec->repeat_time = time(NULL) + rrec->repeat_interval;
|
||||
|
||||
DEBUG(5,("register_name_timeout_response: increasing WINS timeout to %d seconds.\n",
|
||||
rrec->repeat_interval));
|
||||
(int)rrec->repeat_interval));
|
||||
return; /* Don't remove the response record. */
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ responding.\n", inet_ntoa(rrec->packet->ip)));
|
||||
rrec->repeat_time = time(NULL) + rrec->repeat_interval;
|
||||
|
||||
DEBUG(5,("release_name_timeout_response: increasing WINS timeout to %d seconds.\n",
|
||||
rrec->repeat_interval));
|
||||
(int)rrec->repeat_interval));
|
||||
return; /* Don't remove the response record. */
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ static void debug_browse_data(char *outbuf, int len)
|
||||
DEBUGADD( 4, ( "%c", x ) );
|
||||
}
|
||||
|
||||
DEBUGADD( 4, ( " hex ", i ) );
|
||||
DEBUGADD( 4, ( " hex ") );
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
|
@ -398,7 +398,8 @@ void announce_myself_to_domain_master_browser(time_t t)
|
||||
if ((t-announce_timer_last) < (CHECK_TIME_MST_ANNOUNCE * 60))
|
||||
{
|
||||
DEBUG(10,("announce_myself_to_domain_master_browser: t (%d) - last(%d) < %d\n",
|
||||
t, announce_timer_last, CHECK_TIME_MST_ANNOUNCE * 60 ));
|
||||
(int)t, (int)announce_timer_last,
|
||||
CHECK_TIME_MST_ANNOUNCE * 60 ));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2298,67 +2298,46 @@ BOOL lp_snum_ok(int iService)
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
auto-load some homes and printer services
|
||||
auto-load some home services
|
||||
***************************************************************************/
|
||||
static void lp_add_auto_services(char *str)
|
||||
{
|
||||
char *s;
|
||||
char *p;
|
||||
int homes, printers;
|
||||
char *s;
|
||||
char *p;
|
||||
int homes;
|
||||
|
||||
if (!str)
|
||||
return;
|
||||
if (!str) return;
|
||||
|
||||
s = strdup(str);
|
||||
if (!s) return;
|
||||
s = strdup(str);
|
||||
if (!s) return;
|
||||
|
||||
homes = lp_servicenumber(HOMES_NAME);
|
||||
printers = lp_servicenumber(PRINTERS_NAME);
|
||||
|
||||
for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
|
||||
char *home = get_home_dir(p);
|
||||
|
||||
if (lp_servicenumber(p) >= 0) continue;
|
||||
|
||||
if (home && homes >= 0) {
|
||||
lp_add_home(p,homes,home);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (printers >= 0 && pcap_printername_ok(p,NULL)) {
|
||||
lp_add_printer(p,printers);
|
||||
}
|
||||
}
|
||||
free(s);
|
||||
homes = lp_servicenumber(HOMES_NAME);
|
||||
|
||||
for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
|
||||
char *home = get_home_dir(p);
|
||||
|
||||
if (lp_servicenumber(p) >= 0) continue;
|
||||
|
||||
if (home && homes >= 0) {
|
||||
lp_add_home(p,homes,home);
|
||||
}
|
||||
}
|
||||
free(s);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
auto-load one printer
|
||||
***************************************************************************/
|
||||
static void lp_add_one_printer(char *name,char *comment)
|
||||
void lp_add_one_printer(char *name,char *comment)
|
||||
{
|
||||
int printers = lp_servicenumber(PRINTERS_NAME);
|
||||
int i;
|
||||
int printers = lp_servicenumber(PRINTERS_NAME);
|
||||
int i;
|
||||
|
||||
if (lp_servicenumber(name) < 0)
|
||||
{
|
||||
lp_add_printer(name,printers);
|
||||
if ((i=lp_servicenumber(name)) >= 0)
|
||||
string_set(&iSERVICE(i).comment,comment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
auto-load printer services
|
||||
***************************************************************************/
|
||||
static void lp_add_all_printers(void)
|
||||
{
|
||||
int printers = lp_servicenumber(PRINTERS_NAME);
|
||||
|
||||
if (printers < 0) return;
|
||||
|
||||
pcap_printer_fn(lp_add_one_printer);
|
||||
if (lp_servicenumber(name) < 0) {
|
||||
lp_add_printer(name,printers);
|
||||
if ((i=lp_servicenumber(name)) >= 0)
|
||||
string_set(&iSERVICE(i).comment,comment);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
@ -2460,8 +2439,6 @@ BOOL lp_load(char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc)
|
||||
bRetval = service_ok(iServiceIndex);
|
||||
|
||||
lp_add_auto_services(lp_auto_services());
|
||||
if (lp_load_printers())
|
||||
lp_add_all_printers();
|
||||
|
||||
if (add_ipc)
|
||||
lp_add_ipc();
|
||||
@ -2540,26 +2517,6 @@ char *volume_label(int snum)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* nmbd only loads the global section. There seems to be no way to
|
||||
* determine exactly is a service is printable by only looking at the
|
||||
* [global] section so for now always announce as a print server. This
|
||||
* will need looking at in the future. Jeremy (jallison@whistle.com).
|
||||
*/
|
||||
/*******************************************************************
|
||||
Return true if any printer services are defined.
|
||||
******************************************************************/
|
||||
static BOOL lp_printer_services(void)
|
||||
{
|
||||
int iService;
|
||||
|
||||
for (iService = iNumServices - 1; iService >= 0; iService--)
|
||||
if (VALID(iService) && iSERVICE(iService).bPrint_ok)
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************
|
||||
Set the server type we will announce as via nmbd.
|
||||
@ -2575,15 +2532,6 @@ static void set_default_server_announce_type()
|
||||
else if(lp_announce_as() == ANNOUNCE_AS_WFW)
|
||||
default_server_announce |= SV_TYPE_WFW;
|
||||
default_server_announce |= (lp_time_server() ? SV_TYPE_TIME_SOURCE : 0);
|
||||
/*
|
||||
* nmbd only loads the [global] section. There seems to be no way to
|
||||
* determine exactly if any service is printable by only looking at the
|
||||
* [global] section so for now always announce as a print server. This
|
||||
* will need looking at in the future. Jeremy (jallison@whistle.com).
|
||||
*/
|
||||
#if 0
|
||||
default_server_announce |= (lp_printer_services() ? SV_TYPE_PRINTQ_SERVER : 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -248,8 +248,8 @@ static struct smb_passwd *getsmbfilepwent(void *vp)
|
||||
the NT password. */
|
||||
}
|
||||
|
||||
DEBUG(5, ("getsmbfilepwent: returning passwd entry for user %s, uid %d\n",
|
||||
user_name, uidval));
|
||||
DEBUG(5,("getsmbfilepwent: returning passwd entry for user %s, uid %ld\n",
|
||||
user_name, uidval));
|
||||
|
||||
if (*p == '[')
|
||||
{
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
#include "includes.h"
|
||||
extern int DEBUGLEVEL;
|
||||
extern connection_struct Connections[];
|
||||
extern files_struct Files[];
|
||||
|
||||
static BOOL * lpq_cache_reset=NULL;
|
||||
|
||||
@ -51,92 +49,84 @@ Build the print command in the supplied buffer. This means getting the
|
||||
print command for the service and inserting the printer name and the
|
||||
print file name. Return NULL on error, else the passed buffer pointer.
|
||||
****************************************************************************/
|
||||
static char *build_print_command(int cnum, char *command, char *syscmd, char *filename1)
|
||||
static char *build_print_command(connection_struct *conn,
|
||||
char *command,
|
||||
char *syscmd, char *filename1)
|
||||
{
|
||||
int snum = SNUM(cnum);
|
||||
char *tstr;
|
||||
pstring filename;
|
||||
int snum = SNUM(conn);
|
||||
char *tstr;
|
||||
pstring filename;
|
||||
|
||||
/* get the print command for the service. */
|
||||
tstr = command;
|
||||
if (!syscmd || !tstr) {
|
||||
DEBUG(0,("No print command for service `%s'\n", SERVICE(snum)));
|
||||
return (NULL);
|
||||
}
|
||||
/* get the print command for the service. */
|
||||
tstr = command;
|
||||
if (!syscmd || !tstr) {
|
||||
DEBUG(0,("No print command for service `%s'\n",
|
||||
SERVICE(snum)));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* copy the command into the buffer for extensive meddling. */
|
||||
StrnCpy(syscmd, tstr, sizeof(pstring) - 1);
|
||||
/* copy the command into the buffer for extensive meddling. */
|
||||
StrnCpy(syscmd, tstr, sizeof(pstring) - 1);
|
||||
|
||||
/* look for "%s" in the string. If there is no %s, we cannot print. */
|
||||
if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) {
|
||||
DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
|
||||
}
|
||||
/* look for "%s" in the string. If there is no %s, we cannot print. */
|
||||
if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) {
|
||||
DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
|
||||
}
|
||||
|
||||
if (strstr(syscmd,"%s")) {
|
||||
int iOffset = PTR_DIFF(strstr(syscmd, "%s"),syscmd);
|
||||
if (strstr(syscmd,"%s")) {
|
||||
pstrcpy(filename,filename1);
|
||||
|
||||
/* construct the full path for the filename, shouldn't be necessary unless
|
||||
the subshell causes a "cd" to be executed.
|
||||
Only use the full path if there isn't a / preceding the %s */
|
||||
if (iOffset==0 || syscmd[iOffset-1] != '/') {
|
||||
StrnCpy(filename,Connections[cnum].connectpath,sizeof(filename)-1);
|
||||
trim_string(filename,"","/");
|
||||
pstrcat(filename,"/");
|
||||
pstrcat(filename,filename1);
|
||||
}
|
||||
else
|
||||
pstrcpy(filename,filename1);
|
||||
|
||||
string_sub(syscmd, "%s", filename);
|
||||
}
|
||||
string_sub(syscmd, "%s", filename);
|
||||
}
|
||||
|
||||
string_sub(syscmd, "%f", filename1);
|
||||
string_sub(syscmd, "%f", filename1);
|
||||
|
||||
/* Does the service have a printername? If not, make a fake and empty */
|
||||
/* printer name. That way a %p is treated sanely if no printer */
|
||||
/* name was specified to replace it. This eventuality is logged. */
|
||||
tstr = PRINTERNAME(snum);
|
||||
if (tstr == NULL || tstr[0] == '\0') {
|
||||
DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
|
||||
tstr = SERVICE(snum);
|
||||
}
|
||||
/* Does the service have a printername? If not, make a fake
|
||||
and empty */
|
||||
/* printer name. That way a %p is treated sanely if no printer */
|
||||
/* name was specified to replace it. This eventuality is logged. */
|
||||
tstr = PRINTERNAME(snum);
|
||||
if (tstr == NULL || tstr[0] == '\0') {
|
||||
DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
|
||||
tstr = SERVICE(snum);
|
||||
}
|
||||
|
||||
string_sub(syscmd, "%p", tstr);
|
||||
string_sub(syscmd, "%p", tstr);
|
||||
|
||||
standard_sub(cnum,syscmd);
|
||||
standard_sub(conn,syscmd);
|
||||
|
||||
return (syscmd);
|
||||
return (syscmd);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
print a file - called on closing the file
|
||||
****************************************************************************/
|
||||
void print_file(int fnum)
|
||||
void print_file(connection_struct *conn, files_struct *file)
|
||||
{
|
||||
pstring syscmd;
|
||||
int cnum = Files[fnum].cnum;
|
||||
int snum=SNUM(cnum);
|
||||
char *tempstr;
|
||||
pstring syscmd;
|
||||
int snum = SNUM(conn);
|
||||
char *tempstr;
|
||||
|
||||
*syscmd = 0;
|
||||
*syscmd = 0;
|
||||
|
||||
if (file_size(Files[fnum].name) <= 0) {
|
||||
DEBUG(3,("Discarding null print job %s\n",Files[fnum].name));
|
||||
sys_unlink(Files[fnum].name);
|
||||
return;
|
||||
}
|
||||
if (file_size(file->fsp_name) <= 0) {
|
||||
DEBUG(3,("Discarding null print job %s\n",file->fsp_name));
|
||||
sys_unlink(file->fsp_name);
|
||||
return;
|
||||
}
|
||||
|
||||
tempstr = build_print_command(cnum, PRINTCOMMAND(snum), syscmd, Files[fnum].name);
|
||||
if (tempstr != NULL)
|
||||
{
|
||||
int ret = smbrun(syscmd,NULL,False);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
}
|
||||
else
|
||||
DEBUG(0,("Null print command?\n"));
|
||||
tempstr = build_print_command(conn,
|
||||
PRINTCOMMAND(snum),
|
||||
syscmd, file->fsp_name);
|
||||
if (tempstr != NULL) {
|
||||
int ret = smbrun(syscmd,NULL,False);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
} else {
|
||||
DEBUG(0,("Null print command?\n"));
|
||||
}
|
||||
|
||||
lpq_reset(snum);
|
||||
lpq_reset(snum);
|
||||
}
|
||||
|
||||
static char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
@ -1023,105 +1013,102 @@ static BOOL parse_lpq_entry(int snum,char *line,
|
||||
/****************************************************************************
|
||||
get a printer queue
|
||||
****************************************************************************/
|
||||
int get_printqueue(int snum,int cnum,print_queue_struct **queue,
|
||||
int get_printqueue(int snum,
|
||||
connection_struct *conn,print_queue_struct **queue,
|
||||
print_status_struct *status)
|
||||
{
|
||||
char *lpq_command = lp_lpqcommand(snum);
|
||||
char *printername = PRINTERNAME(snum);
|
||||
int ret=0,count=0;
|
||||
pstring syscmd;
|
||||
fstring outfile;
|
||||
pstring line;
|
||||
FILE *f;
|
||||
struct stat sbuf;
|
||||
BOOL dorun=True;
|
||||
int cachetime = lp_lpqcachetime();
|
||||
|
||||
*line = 0;
|
||||
check_lpq_cache(snum);
|
||||
|
||||
if (!printername || !*printername)
|
||||
{
|
||||
DEBUG(6,("xx replacing printer name with service (snum=(%s,%d))\n",
|
||||
lp_servicename(snum),snum));
|
||||
printername = lp_servicename(snum);
|
||||
}
|
||||
char *lpq_command = lp_lpqcommand(snum);
|
||||
char *printername = PRINTERNAME(snum);
|
||||
int ret=0,count=0;
|
||||
pstring syscmd;
|
||||
fstring outfile;
|
||||
pstring line;
|
||||
FILE *f;
|
||||
struct stat sbuf;
|
||||
BOOL dorun=True;
|
||||
int cachetime = lp_lpqcachetime();
|
||||
|
||||
*line = 0;
|
||||
check_lpq_cache(snum);
|
||||
|
||||
if (!printername || !*printername) {
|
||||
DEBUG(6,("xx replacing printer name with service (snum=(%s,%d))\n",
|
||||
lp_servicename(snum),snum));
|
||||
printername = lp_servicename(snum);
|
||||
}
|
||||
|
||||
if (!lpq_command || !(*lpq_command))
|
||||
{
|
||||
DEBUG(5,("No lpq command\n"));
|
||||
return(0);
|
||||
}
|
||||
if (!lpq_command || !(*lpq_command)) {
|
||||
DEBUG(5,("No lpq command\n"));
|
||||
return(0);
|
||||
}
|
||||
|
||||
pstrcpy(syscmd,lpq_command);
|
||||
string_sub(syscmd,"%p",printername);
|
||||
pstrcpy(syscmd,lpq_command);
|
||||
string_sub(syscmd,"%p",printername);
|
||||
|
||||
standard_sub(cnum,syscmd);
|
||||
standard_sub(conn,syscmd);
|
||||
|
||||
slprintf(outfile,sizeof(outfile)-1, "%s/lpq.%08x",tmpdir(),str_checksum(syscmd));
|
||||
slprintf(outfile,sizeof(outfile)-1, "%s/lpq.%08x",tmpdir(),str_checksum(syscmd));
|
||||
|
||||
if (!lpq_cache_reset[snum] && cachetime && !stat(outfile,&sbuf))
|
||||
{
|
||||
if (time(NULL) - sbuf.st_mtime < cachetime) {
|
||||
DEBUG(3,("Using cached lpq output\n"));
|
||||
dorun = False;
|
||||
}
|
||||
}
|
||||
|
||||
if (dorun) {
|
||||
ret = smbrun(syscmd,outfile,True);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
}
|
||||
|
||||
lpq_cache_reset[snum] = False;
|
||||
|
||||
f = fopen(outfile,"r");
|
||||
if (!f) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (status) {
|
||||
fstrcpy(status->message,"");
|
||||
status->status = LPSTAT_OK;
|
||||
}
|
||||
|
||||
while (fgets(line,sizeof(pstring),f))
|
||||
{
|
||||
DEBUG(6,("QUEUE2: %s\n",line));
|
||||
|
||||
*queue = Realloc(*queue,sizeof(print_queue_struct)*(count+1));
|
||||
if (! *queue)
|
||||
{
|
||||
count = 0;
|
||||
break;
|
||||
if (!lpq_cache_reset[snum] && cachetime && !stat(outfile,&sbuf)) {
|
||||
if (time(NULL) - sbuf.st_mtime < cachetime) {
|
||||
DEBUG(3,("Using cached lpq output\n"));
|
||||
dorun = False;
|
||||
}
|
||||
}
|
||||
|
||||
bzero((char *)&(*queue)[count],sizeof(**queue));
|
||||
|
||||
/* parse it */
|
||||
if (!parse_lpq_entry(snum,line,&(*queue)[count],status,count==0))
|
||||
continue;
|
||||
|
||||
count++;
|
||||
}
|
||||
if (dorun) {
|
||||
ret = smbrun(syscmd,outfile,True);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
lpq_cache_reset[snum] = False;
|
||||
|
||||
if (!cachetime) {
|
||||
unlink(outfile);
|
||||
} else {
|
||||
/* we only expect this to succeed on trapdoor systems, on normal systems
|
||||
the file is owned by root */
|
||||
chmod(outfile,0666);
|
||||
}
|
||||
return(count);
|
||||
f = fopen(outfile,"r");
|
||||
if (!f) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (status) {
|
||||
fstrcpy(status->message,"");
|
||||
status->status = LPSTAT_OK;
|
||||
}
|
||||
|
||||
while (fgets(line,sizeof(pstring),f)) {
|
||||
DEBUG(6,("QUEUE2: %s\n",line));
|
||||
|
||||
*queue = Realloc(*queue,sizeof(print_queue_struct)*(count+1));
|
||||
if (! *queue) {
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
bzero((char *)&(*queue)[count],sizeof(**queue));
|
||||
|
||||
/* parse it */
|
||||
if (!parse_lpq_entry(snum,line,
|
||||
&(*queue)[count],status,count==0))
|
||||
continue;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
if (!cachetime) {
|
||||
unlink(outfile);
|
||||
} else {
|
||||
/* we only expect this to succeed on trapdoor systems,
|
||||
on normal systems the file is owned by root */
|
||||
chmod(outfile,0666);
|
||||
}
|
||||
return(count);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
delete a printer queue entry
|
||||
****************************************************************************/
|
||||
void del_printqueue(int cnum,int snum,int jobid)
|
||||
void del_printqueue(connection_struct *conn,int snum,int jobid)
|
||||
{
|
||||
char *lprm_command = lp_lprmcommand(snum);
|
||||
char *printername = PRINTERNAME(snum);
|
||||
@ -1147,7 +1134,7 @@ void del_printqueue(int cnum,int snum,int jobid)
|
||||
pstrcpy(syscmd,lprm_command);
|
||||
string_sub(syscmd,"%p",printername);
|
||||
string_sub(syscmd,"%j",jobstr);
|
||||
standard_sub(cnum,syscmd);
|
||||
standard_sub(conn,syscmd);
|
||||
|
||||
ret = smbrun(syscmd,NULL,False);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
@ -1157,7 +1144,7 @@ void del_printqueue(int cnum,int snum,int jobid)
|
||||
/****************************************************************************
|
||||
change status of a printer queue entry
|
||||
****************************************************************************/
|
||||
void status_printjob(int cnum,int snum,int jobid,int status)
|
||||
void status_printjob(connection_struct *conn,int snum,int jobid,int status)
|
||||
{
|
||||
char *lpstatus_command =
|
||||
(status==LPQ_PAUSED?lp_lppausecommand(snum):lp_lpresumecommand(snum));
|
||||
@ -1185,7 +1172,7 @@ void status_printjob(int cnum,int snum,int jobid,int status)
|
||||
pstrcpy(syscmd,lpstatus_command);
|
||||
string_sub(syscmd,"%p",printername);
|
||||
string_sub(syscmd,"%j",jobstr);
|
||||
standard_sub(cnum,syscmd);
|
||||
standard_sub(conn,syscmd);
|
||||
|
||||
ret = smbrun(syscmd,NULL,False);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
@ -1218,7 +1205,7 @@ void printjob_decode(int jobid, int *snum, int *job)
|
||||
Change status of a printer queue
|
||||
****************************************************************************/
|
||||
|
||||
void status_printqueue(int cnum,int snum,int status)
|
||||
void status_printqueue(connection_struct *conn,int snum,int status)
|
||||
{
|
||||
char *queuestatus_command = (status==LPSTAT_STOPPED ?
|
||||
lp_queuepausecommand(snum):lp_queueresumecommand(snum));
|
||||
@ -1240,9 +1227,57 @@ void status_printqueue(int cnum,int snum,int status)
|
||||
|
||||
pstrcpy(syscmd,queuestatus_command);
|
||||
string_sub(syscmd,"%p",printername);
|
||||
standard_sub(cnum,syscmd);
|
||||
standard_sub(conn,syscmd);
|
||||
|
||||
ret = smbrun(syscmd,NULL,False);
|
||||
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
|
||||
lpq_reset(snum); /* queue has changed */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
auto-load printer services
|
||||
***************************************************************************/
|
||||
static void add_all_printers(void)
|
||||
{
|
||||
int printers = lp_servicenumber(PRINTERS_NAME);
|
||||
|
||||
if (printers < 0) return;
|
||||
|
||||
pcap_printer_fn(lp_add_one_printer);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
auto-load some homes and printer services
|
||||
***************************************************************************/
|
||||
static void add_auto_printers(void)
|
||||
{
|
||||
char *p;
|
||||
int printers;
|
||||
char *str = lp_auto_services();
|
||||
|
||||
if (!str) return;
|
||||
|
||||
printers = lp_servicenumber(PRINTERS_NAME);
|
||||
|
||||
if (printers < 0) return;
|
||||
|
||||
for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
|
||||
if (lp_servicenumber(p) >= 0) continue;
|
||||
|
||||
if (pcap_printername_ok(p,NULL)) {
|
||||
lp_add_printer(p,printers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
load automatic printer services
|
||||
***************************************************************************/
|
||||
void load_printers(void)
|
||||
{
|
||||
add_auto_printers();
|
||||
if (lp_load_printers())
|
||||
add_all_printers();
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan,
|
||||
|
||||
/* create and send a MSRPC command with api NET_AUTH2 */
|
||||
|
||||
DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %lx\n",
|
||||
DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n",
|
||||
cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname,
|
||||
credstr(cli->clnt_cred.challenge.data), neg_flags));
|
||||
|
||||
@ -171,7 +171,7 @@ password ?).\n", cli->desthost ));
|
||||
if (ok && r_a.srv_flgs.neg_flags != q_a.clnt_flgs.neg_flags)
|
||||
{
|
||||
/* report different neg_flags */
|
||||
DEBUG(0,("cli_net_auth2: error neg_flags (q,r) differ - (%lx,%lx)\n",
|
||||
DEBUG(0,("cli_net_auth2: error neg_flags (q,r) differ - (%x,%x)\n",
|
||||
q_a.clnt_flgs.neg_flags, r_a.srv_flgs.neg_flags));
|
||||
ok = False;
|
||||
}
|
||||
@ -264,7 +264,7 @@ BOOL cli_net_srv_pwset(struct cli_state *cli, uint8 hashed_mach_pwd[16])
|
||||
|
||||
/* create and send a MSRPC command with api NET_SRV_PWSET */
|
||||
|
||||
DEBUG(4,("cli_net_srv_pwset: srv:%s acct:%s sc: %d mc: %s clnt %s %lx\n",
|
||||
DEBUG(4,("cli_net_srv_pwset: srv:%s acct:%s sc: %d mc: %s clnt %s %x\n",
|
||||
cli->srv_name_slash, cli->mach_acct, sec_chan_type, global_myname,
|
||||
credstr(new_clnt_cred.challenge.data), new_clnt_cred.timestamp.time));
|
||||
|
||||
@ -331,7 +331,7 @@ BOOL cli_net_sam_logon(struct cli_state *cli, NET_ID_INFO_CTR *ctr,
|
||||
|
||||
/* create and send a MSRPC command with api NET_SAMLOGON */
|
||||
|
||||
DEBUG(4,("cli_net_sam_logon: srv:%s mc:%s clnt %s %lx ll: %d\n",
|
||||
DEBUG(4,("cli_net_sam_logon: srv:%s mc:%s clnt %s %x ll: %d\n",
|
||||
cli->srv_name_slash, global_myname,
|
||||
credstr(new_clnt_cred.challenge.data), cli->clnt_cred.timestamp.time,
|
||||
ctr->switch_value));
|
||||
@ -416,7 +416,7 @@ BOOL cli_net_sam_logoff(struct cli_state *cli, NET_ID_INFO_CTR *ctr)
|
||||
|
||||
/* create and send a MSRPC command with api NET_SAMLOGOFF */
|
||||
|
||||
DEBUG(4,("cli_net_sam_logoff: srv:%s mc:%s clnt %s %lx ll: %d\n",
|
||||
DEBUG(4,("cli_net_sam_logoff: srv:%s mc:%s clnt %s %x ll: %d\n",
|
||||
cli->srv_name_slash, global_myname,
|
||||
credstr(new_clnt_cred.challenge.data), new_clnt_cred.timestamp.time,
|
||||
ctr->switch_value));
|
||||
|
@ -140,7 +140,7 @@ void lsa_io_obj_attr(char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps, int depth)
|
||||
|
||||
if (attr->len != ps->offset - start)
|
||||
{
|
||||
DEBUG(3,("lsa_io_obj_attr: length %lx does not match size %lx\n",
|
||||
DEBUG(3,("lsa_io_obj_attr: length %x does not match size %x\n",
|
||||
attr->len, ps->offset - start));
|
||||
}
|
||||
}
|
||||
|
@ -721,7 +721,8 @@ void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
|
||||
if (num_sam_entries >= MAX_SAM_ENTRIES)
|
||||
{
|
||||
num_sam_entries = MAX_SAM_ENTRIES;
|
||||
DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
|
||||
DEBUG(5,("limiting number of entries to %d\n",
|
||||
num_sam_entries));
|
||||
}
|
||||
|
||||
r_u->total_num_entries = total_num_entries;
|
||||
@ -853,7 +854,8 @@ void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
|
||||
if (num_sam_entries >= MAX_SAM_ENTRIES)
|
||||
{
|
||||
num_sam_entries = MAX_SAM_ENTRIES;
|
||||
DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
|
||||
DEBUG(5,("limiting number of entries to %d\n",
|
||||
num_sam_entries));
|
||||
}
|
||||
|
||||
r_u->num_entries = num_sam_entries;
|
||||
@ -988,7 +990,8 @@ void make_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
|
||||
if (num_sam_entries >= MAX_SAM_ENTRIES)
|
||||
{
|
||||
num_sam_entries = MAX_SAM_ENTRIES;
|
||||
DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
|
||||
DEBUG(5,("limiting number of entries to %d\n",
|
||||
num_sam_entries));
|
||||
}
|
||||
|
||||
for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
|
||||
@ -1065,7 +1068,8 @@ void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
|
||||
if (num_sam_entries >= MAX_SAM_ENTRIES)
|
||||
{
|
||||
num_sam_entries = MAX_SAM_ENTRIES;
|
||||
DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
|
||||
DEBUG(5,("limiting number of entries to %d\n",
|
||||
num_sam_entries));
|
||||
}
|
||||
|
||||
for (i = start_idx, entries_added = 0; i < num_sam_entries; i++)
|
||||
@ -1261,7 +1265,8 @@ void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
|
||||
if (num_sam_entries >= MAX_SAM_ENTRIES)
|
||||
{
|
||||
num_sam_entries = MAX_SAM_ENTRIES;
|
||||
DEBUG(5,("limiting number of entries to %d %s\n", num_sam_entries));
|
||||
DEBUG(5,("limiting number of entries to %d\n",
|
||||
num_sam_entries));
|
||||
}
|
||||
|
||||
if (status == 0x0)
|
||||
|
@ -1364,7 +1364,7 @@ void srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth)
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG(5,("%s% no server info at switch_value %d\n",
|
||||
DEBUG(5,("%s no server info at switch_value %d\n",
|
||||
tab_depth(depth), ctr->switch_value));
|
||||
break;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ static int chain_pnum = -1;
|
||||
pipes_struct Pipes[MAX_OPEN_PIPES];
|
||||
|
||||
#define P_OPEN(p) ((p)->open)
|
||||
#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->cnum))
|
||||
#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->conn))
|
||||
#define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES))
|
||||
#define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && P_OPEN(&(Pipes[pnum])))
|
||||
#define PNUM_OK(pnum,c) (OPEN_PNUM(pnum) && (c)==Pipes[pnum].cnum)
|
||||
@ -93,44 +93,43 @@ void init_rpc_pipe_hnd(void)
|
||||
/****************************************************************************
|
||||
find first available file slot
|
||||
****************************************************************************/
|
||||
int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid)
|
||||
int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid)
|
||||
{
|
||||
int i;
|
||||
/* we start at 1 here for an obscure reason I can't now remember,
|
||||
but I think is important :-) */
|
||||
for (i = 1; i < MAX_OPEN_PIPES; i++)
|
||||
{
|
||||
if (!Pipes[i].open)
|
||||
{
|
||||
Pipes[i].open = True;
|
||||
Pipes[i].device_state = 0;
|
||||
Pipes[i].cnum = cnum;
|
||||
Pipes[i].uid = vuid;
|
||||
|
||||
Pipes[i].rhdr.data = NULL;
|
||||
Pipes[i].rdata.data = NULL;
|
||||
Pipes[i].rhdr.offset = 0;
|
||||
Pipes[i].rdata.offset = 0;
|
||||
|
||||
Pipes[i].file_offset = 0;
|
||||
Pipes[i].hdr_offsets = 0;
|
||||
Pipes[i].frag_len_left = 0;
|
||||
Pipes[i].next_frag_start = 0;
|
||||
|
||||
fstrcpy(Pipes[i].name, pipe_name);
|
||||
|
||||
DEBUG(4,("Opened pipe %s with handle %x\n",
|
||||
pipe_name, i + PIPE_HANDLE_OFFSET));
|
||||
|
||||
set_chain_pnum(i);
|
||||
|
||||
return(i);
|
||||
}
|
||||
for (i = 1; i < MAX_OPEN_PIPES; i++) {
|
||||
if (!Pipes[i].open) break;
|
||||
}
|
||||
|
||||
DEBUG(1,("ERROR! Out of pipe structures - perhaps increase MAX_OPEN_PIPES?\n"));
|
||||
if (i == MAX_OPEN_PIPES) {
|
||||
DEBUG(1,("ERROR! Out of pipe structures\n"));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
Pipes[i].open = True;
|
||||
Pipes[i].device_state = 0;
|
||||
Pipes[i].conn = conn;
|
||||
Pipes[i].uid = vuid;
|
||||
|
||||
Pipes[i].rhdr.data = NULL;
|
||||
Pipes[i].rdata.data = NULL;
|
||||
Pipes[i].rhdr.offset = 0;
|
||||
Pipes[i].rdata.offset = 0;
|
||||
|
||||
Pipes[i].file_offset = 0;
|
||||
Pipes[i].hdr_offsets = 0;
|
||||
Pipes[i].frag_len_left = 0;
|
||||
Pipes[i].next_frag_start = 0;
|
||||
|
||||
fstrcpy(Pipes[i].name, pipe_name);
|
||||
|
||||
DEBUG(4,("Opened pipe %s with handle %x\n",
|
||||
pipe_name, i + PIPE_HANDLE_OFFSET));
|
||||
|
||||
set_chain_pnum(i);
|
||||
|
||||
return(i);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -151,9 +150,8 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n)
|
||||
|
||||
if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET))
|
||||
{
|
||||
DEBUG(6,("name: %s cnum: %d open: %s pos: %d len: %d",
|
||||
DEBUG(6,("name: %s open: %s pos: %d len: %d",
|
||||
p->name,
|
||||
p->cnum,
|
||||
BOOLSTR(p->open),
|
||||
pos, n));
|
||||
}
|
||||
@ -269,9 +267,8 @@ BOOL get_rpc_pipe(int pnum, pipes_struct **p)
|
||||
|
||||
if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET))
|
||||
{
|
||||
DEBUG(6,("name: %s cnum: %d open: %s ",
|
||||
DEBUG(6,("name: %s open: %s ",
|
||||
Pipes[pnum - PIPE_HANDLE_OFFSET].name,
|
||||
Pipes[pnum - PIPE_HANDLE_OFFSET].cnum,
|
||||
BOOLSTR(Pipes[pnum - PIPE_HANDLE_OFFSET].open)));
|
||||
}
|
||||
if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET))
|
||||
@ -306,8 +303,8 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state)
|
||||
|
||||
if (P_OPEN(p))
|
||||
{
|
||||
DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s cnum=%d)\n",
|
||||
timestring(), device_state, p->name, p->cnum));
|
||||
DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s)\n",
|
||||
timestring(), device_state, p->name));
|
||||
|
||||
p->device_state = device_state;
|
||||
|
||||
@ -315,8 +312,8 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state)
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(3,("%s Error setting pipe device state=%x (name=%s cnum=%d)\n",
|
||||
timestring(), device_state, p->name, p->cnum));
|
||||
DEBUG(3,("%s Error setting pipe device state=%x (name=%s)\n",
|
||||
timestring(), device_state, p->name));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -324,32 +321,30 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state)
|
||||
/****************************************************************************
|
||||
close an rpc pipe
|
||||
****************************************************************************/
|
||||
BOOL close_rpc_pipe_hnd(int pnum, int cnum)
|
||||
BOOL close_rpc_pipe_hnd(int pnum, connection_struct *conn)
|
||||
{
|
||||
pipes_struct *p = NULL;
|
||||
get_rpc_pipe(pnum, &p);
|
||||
/* mapping is PIPE_HANDLE_OFFSET up... */
|
||||
/* mapping is PIPE_HANDLE_OFFSET up... */
|
||||
|
||||
if (p != NULL && P_OK(p, cnum))
|
||||
{
|
||||
DEBUG(3,("%s Closed pipe name %s pnum=%x cnum=%d\n",
|
||||
timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name, pnum,cnum));
|
||||
if (p != NULL && P_OK(p, conn)) {
|
||||
DEBUG(3,("%s Closed pipe name %s pnum=%x\n",
|
||||
timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name,
|
||||
pnum));
|
||||
|
||||
p->open = False;
|
||||
|
||||
p->rdata.offset = 0;
|
||||
p->rhdr.offset = 0;
|
||||
mem_buf_free(&(p->rdata.data));
|
||||
mem_buf_free(&(p->rhdr .data));
|
||||
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(3,("%s Error closing pipe pnum=%x cnum=%d\n",
|
||||
timestring(),pnum, cnum));
|
||||
return False;
|
||||
}
|
||||
p->open = False;
|
||||
|
||||
p->rdata.offset = 0;
|
||||
p->rhdr.offset = 0;
|
||||
mem_buf_free(&(p->rdata.data));
|
||||
mem_buf_free(&(p->rhdr .data));
|
||||
|
||||
return True;
|
||||
} else {
|
||||
DEBUG(3,("%s Error closing pipe pnum=%x\n",
|
||||
timestring(),pnum));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -80,7 +80,7 @@ END {
|
||||
next;
|
||||
}
|
||||
|
||||
!/^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE/ {
|
||||
!/^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE/ {
|
||||
next;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ static int findpty(char **slave)
|
||||
#else /* HAVE_GRANTPT */
|
||||
fstrcpy( line, "/dev/ptyXX" );
|
||||
|
||||
dirp = OpenDir(-1, "/dev", False);
|
||||
dirp = OpenDir(NULL, "/dev", False);
|
||||
if (!dirp) return(-1);
|
||||
while ((dpname = ReadDirName(dirp)) != NULL) {
|
||||
if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "includes.h"
|
||||
|
||||
|
||||
extern connection_struct Connections[MAX_CONNECTIONS];
|
||||
extern fstring remote_machine;
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
@ -30,7 +29,7 @@ extern int DEBUGLEVEL;
|
||||
/****************************************************************************
|
||||
simple routines to do connection counting
|
||||
****************************************************************************/
|
||||
BOOL yield_connection(int cnum,char *name,int max_connections)
|
||||
BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
|
||||
{
|
||||
struct connect_record crec;
|
||||
pstring fname;
|
||||
@ -38,7 +37,7 @@ BOOL yield_connection(int cnum,char *name,int max_connections)
|
||||
int mypid = getpid();
|
||||
int i;
|
||||
|
||||
DEBUG(3,("Yielding connection to %d %s\n",cnum,name));
|
||||
DEBUG(3,("Yielding connection to %s\n",name));
|
||||
|
||||
if (max_connections <= 0)
|
||||
return(True);
|
||||
@ -73,11 +72,11 @@ BOOL yield_connection(int cnum,char *name,int max_connections)
|
||||
close(fd);
|
||||
return(False);
|
||||
}
|
||||
if (crec.pid == mypid && crec.cnum == cnum)
|
||||
if (crec.pid == mypid && crec.cnum == conn->cnum)
|
||||
break;
|
||||
}
|
||||
|
||||
if (crec.pid != mypid || crec.cnum != cnum) {
|
||||
if (crec.pid != mypid || crec.cnum != conn->cnum) {
|
||||
if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
|
||||
DEBUG(0,("ERROR: can't release lock on %s\n", fname));
|
||||
}
|
||||
@ -113,7 +112,7 @@ BOOL yield_connection(int cnum,char *name,int max_connections)
|
||||
/****************************************************************************
|
||||
simple routines to do connection counting
|
||||
****************************************************************************/
|
||||
BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear)
|
||||
BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear)
|
||||
{
|
||||
extern int Client;
|
||||
struct connect_record crec;
|
||||
@ -192,11 +191,14 @@ BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear)
|
||||
bzero((void *)&crec,sizeof(crec));
|
||||
crec.magic = 0x280267;
|
||||
crec.pid = getpid();
|
||||
crec.cnum = cnum;
|
||||
if (cnum != -1) {
|
||||
crec.uid = Connections[cnum].uid;
|
||||
crec.gid = Connections[cnum].gid;
|
||||
StrnCpy(crec.name,lp_servicename(SNUM(cnum)),sizeof(crec.name)-1);
|
||||
if (conn) {
|
||||
crec.cnum = conn->cnum;
|
||||
crec.uid = conn->uid;
|
||||
crec.gid = conn->gid;
|
||||
StrnCpy(crec.name,
|
||||
lp_servicename(SNUM(conn)),sizeof(crec.name)-1);
|
||||
} else {
|
||||
crec.cnum = -1;
|
||||
}
|
||||
crec.start = time(NULL);
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern connection_struct Connections[];
|
||||
|
||||
/*
|
||||
This module implements directory related functions for Samba.
|
||||
@ -36,18 +35,17 @@ static uint32 dircounter = 0;
|
||||
#define NUMDIRPTRS 256
|
||||
|
||||
|
||||
static struct dptr_struct
|
||||
{
|
||||
int pid;
|
||||
int cnum;
|
||||
uint32 lastused;
|
||||
void *ptr;
|
||||
BOOL valid;
|
||||
BOOL finished;
|
||||
BOOL expect_close;
|
||||
char *wcard; /* Field only used for lanman2 trans2_findfirst/next searches */
|
||||
uint16 attr; /* Field only used for lanman2 trans2_findfirst/next searches */
|
||||
char *path;
|
||||
static struct dptr_struct {
|
||||
int pid;
|
||||
connection_struct *conn;
|
||||
uint32 lastused;
|
||||
void *ptr;
|
||||
BOOL valid;
|
||||
BOOL finished;
|
||||
BOOL expect_close;
|
||||
char *wcard; /* Field only used for trans2_ searches */
|
||||
uint16 attr; /* Field only used for trans2_ searches */
|
||||
char *path;
|
||||
}
|
||||
dirptrs[NUMDIRPTRS];
|
||||
|
||||
@ -110,20 +108,20 @@ get the dir ptr for a dir index
|
||||
****************************************************************************/
|
||||
static void *dptr_get(int key,uint32 lastused)
|
||||
{
|
||||
struct dptr_struct *dp = &dirptrs[key];
|
||||
struct dptr_struct *dp = &dirptrs[key];
|
||||
|
||||
if (dp->valid) {
|
||||
if (lastused) dp->lastused = lastused;
|
||||
if (!dp->ptr) {
|
||||
if (dptrs_open >= MAX_OPEN_DIRECTORIES)
|
||||
dptr_idleoldest();
|
||||
DEBUG(4,("Reopening dptr key %d\n",key));
|
||||
if ((dp->ptr = OpenDir(dp->cnum, dp->path, True)))
|
||||
dptrs_open++;
|
||||
}
|
||||
return(dp->ptr);
|
||||
}
|
||||
return(NULL);
|
||||
if (dp->valid) {
|
||||
if (lastused) dp->lastused = lastused;
|
||||
if (!dp->ptr) {
|
||||
if (dptrs_open >= MAX_OPEN_DIRECTORIES)
|
||||
dptr_idleoldest();
|
||||
DEBUG(4,("Reopening dptr key %d\n",key));
|
||||
if ((dp->ptr = OpenDir(dp->conn, dp->path, True)))
|
||||
dptrs_open++;
|
||||
}
|
||||
return(dp->ptr);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -217,22 +215,22 @@ void dptr_close(int key)
|
||||
/****************************************************************************
|
||||
close all dptrs for a cnum
|
||||
****************************************************************************/
|
||||
void dptr_closecnum(int cnum)
|
||||
void dptr_closecnum(connection_struct *conn)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<NUMDIRPTRS;i++)
|
||||
if (dirptrs[i].valid && dirptrs[i].cnum == cnum)
|
||||
if (dirptrs[i].valid && dirptrs[i].conn == conn)
|
||||
dptr_close(i);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
idle all dptrs for a cnum
|
||||
****************************************************************************/
|
||||
void dptr_idlecnum(int cnum)
|
||||
void dptr_idlecnum(connection_struct *conn)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<NUMDIRPTRS;i++)
|
||||
if (dirptrs[i].valid && dirptrs[i].cnum == cnum && dirptrs[i].ptr)
|
||||
if (dirptrs[i].valid && dirptrs[i].conn == conn && dirptrs[i].ptr)
|
||||
dptr_idle(i);
|
||||
}
|
||||
|
||||
@ -251,37 +249,37 @@ void dptr_closepath(char *path,int pid)
|
||||
/****************************************************************************
|
||||
start a directory listing
|
||||
****************************************************************************/
|
||||
static BOOL start_dir(int cnum,char *directory)
|
||||
static BOOL start_dir(connection_struct *conn,char *directory)
|
||||
{
|
||||
DEBUG(5,("start_dir cnum=%d dir=%s\n",cnum,directory));
|
||||
DEBUG(5,("start_dir dir=%s\n",directory));
|
||||
|
||||
if (!check_name(directory,cnum))
|
||||
return(False);
|
||||
if (!check_name(directory,conn))
|
||||
return(False);
|
||||
|
||||
if (! *directory)
|
||||
directory = ".";
|
||||
if (! *directory)
|
||||
directory = ".";
|
||||
|
||||
Connections[cnum].dirptr = OpenDir(cnum, directory, True);
|
||||
if (Connections[cnum].dirptr) {
|
||||
dptrs_open++;
|
||||
string_set(&Connections[cnum].dirpath,directory);
|
||||
return(True);
|
||||
}
|
||||
conn->dirptr = OpenDir(conn, directory, True);
|
||||
if (conn->dirptr) {
|
||||
dptrs_open++;
|
||||
string_set(&conn->dirpath,directory);
|
||||
return(True);
|
||||
}
|
||||
|
||||
return(False);
|
||||
return(False);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
create a new dir ptr
|
||||
****************************************************************************/
|
||||
int dptr_create(int cnum,char *path, BOOL expect_close,int pid)
|
||||
int dptr_create(connection_struct *conn,char *path, BOOL expect_close,int pid)
|
||||
{
|
||||
int i;
|
||||
uint32 old;
|
||||
int oldi;
|
||||
|
||||
if (!start_dir(cnum,path))
|
||||
if (!start_dir(conn,path))
|
||||
return(-2); /* Code to say use a unix error return code. */
|
||||
|
||||
if (dptrs_open >= MAX_OPEN_DIRECTORIES)
|
||||
@ -325,11 +323,11 @@ int dptr_create(int cnum,char *path, BOOL expect_close,int pid)
|
||||
if (dirptrs[i].valid)
|
||||
dptr_close(i);
|
||||
|
||||
dirptrs[i].ptr = Connections[cnum].dirptr;
|
||||
dirptrs[i].ptr = conn->dirptr;
|
||||
string_set(&dirptrs[i].path,path);
|
||||
dirptrs[i].lastused = dircounter++;
|
||||
dirptrs[i].finished = False;
|
||||
dirptrs[i].cnum = cnum;
|
||||
dirptrs[i].conn = conn;
|
||||
dirptrs[i].pid = pid;
|
||||
dirptrs[i].expect_close = expect_close;
|
||||
dirptrs[i].wcard = NULL; /* Only used in lanman2 searches */
|
||||
@ -357,7 +355,7 @@ BOOL dptr_fill(char *buf1,unsigned int key)
|
||||
return(False);
|
||||
}
|
||||
offset = TellDir(p);
|
||||
DEBUG(6,("fill on key %d dirptr 0x%x now at %d\n",key,p,offset));
|
||||
DEBUG(6,("fill on key %d dirptr 0x%x now at %d\n",key,(unsigned)p,offset));
|
||||
buf[0] = key;
|
||||
SIVAL(buf,1,offset | DPTR_MASK);
|
||||
return(True);
|
||||
@ -410,7 +408,7 @@ void *dptr_fetch_lanman2(int dptr_num)
|
||||
/****************************************************************************
|
||||
check a filetype for being valid
|
||||
****************************************************************************/
|
||||
BOOL dir_check_ftype(int cnum,int mode,struct stat *st,int dirtype)
|
||||
BOOL dir_check_ftype(connection_struct *conn,int mode,struct stat *st,int dirtype)
|
||||
{
|
||||
if (((mode & ~dirtype) & (aHIDDEN | aSYSTEM | aDIR)) != 0)
|
||||
return False;
|
||||
@ -420,7 +418,7 @@ BOOL dir_check_ftype(int cnum,int mode,struct stat *st,int dirtype)
|
||||
/****************************************************************************
|
||||
get a directory entry
|
||||
****************************************************************************/
|
||||
BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend)
|
||||
BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend)
|
||||
{
|
||||
char *dname;
|
||||
BOOL found = False;
|
||||
@ -434,22 +432,22 @@ BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mo
|
||||
|
||||
*path = *pathreal = *filename = 0;
|
||||
|
||||
isrootdir = (strequal(Connections[cnum].dirpath,"./") ||
|
||||
strequal(Connections[cnum].dirpath,".") ||
|
||||
strequal(Connections[cnum].dirpath,"/"));
|
||||
isrootdir = (strequal(conn->dirpath,"./") ||
|
||||
strequal(conn->dirpath,".") ||
|
||||
strequal(conn->dirpath,"/"));
|
||||
|
||||
needslash =
|
||||
( Connections[cnum].dirpath[strlen(Connections[cnum].dirpath) -1] != '/');
|
||||
( conn->dirpath[strlen(conn->dirpath) -1] != '/');
|
||||
|
||||
if (!Connections[cnum].dirptr)
|
||||
if (!conn->dirptr)
|
||||
return(False);
|
||||
|
||||
while (!found)
|
||||
{
|
||||
dname = ReadDirName(Connections[cnum].dirptr);
|
||||
dname = ReadDirName(conn->dirptr);
|
||||
|
||||
DEBUG(6,("readdir on dirptr 0x%x now at offset %d\n",
|
||||
Connections[cnum].dirptr,TellDir(Connections[cnum].dirptr)));
|
||||
(unsigned)conn->dirptr,TellDir(conn->dirptr)));
|
||||
|
||||
if (dname == NULL)
|
||||
return(False);
|
||||
@ -459,7 +457,7 @@ BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mo
|
||||
pstrcpy(filename,dname);
|
||||
|
||||
if ((strcmp(filename,mask) == 0) ||
|
||||
(name_map_mangle(filename,True,SNUM(cnum)) &&
|
||||
(name_map_mangle(filename,True,SNUM(conn)) &&
|
||||
mask_match(filename,mask,False,False)))
|
||||
{
|
||||
if (isrootdir && (strequal(filename,"..") || strequal(filename,".")))
|
||||
@ -467,7 +465,7 @@ BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mo
|
||||
|
||||
pstrcpy(fname,filename);
|
||||
*path = 0;
|
||||
pstrcpy(path,Connections[cnum].dirpath);
|
||||
pstrcpy(path,conn->dirpath);
|
||||
if(needslash)
|
||||
pstrcat(path,"/");
|
||||
pstrcpy(pathreal,path);
|
||||
@ -483,9 +481,9 @@ BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mo
|
||||
!strequal(fname,".") && !strequal(fname,".."))
|
||||
continue;
|
||||
|
||||
*mode = dos_mode(cnum,pathreal,&sbuf);
|
||||
*mode = dos_mode(conn,pathreal,&sbuf);
|
||||
|
||||
if (!dir_check_ftype(cnum,*mode,&sbuf,dirtype)) {
|
||||
if (!dir_check_ftype(conn,*mode,&sbuf,dirtype)) {
|
||||
DEBUG(5,("[%s] attribs didn't match %x\n",filename,dirtype));
|
||||
continue;
|
||||
}
|
||||
@ -517,7 +515,7 @@ typedef struct
|
||||
/*******************************************************************
|
||||
open a directory
|
||||
********************************************************************/
|
||||
void *OpenDir(int cnum, char *name, BOOL use_veto)
|
||||
void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
|
||||
{
|
||||
Dir *dirp;
|
||||
char *n;
|
||||
@ -538,7 +536,7 @@ void *OpenDir(int cnum, char *name, BOOL use_veto)
|
||||
int l = strlen(n)+1;
|
||||
|
||||
/* If it's a vetoed file, pretend it doesn't even exist */
|
||||
if (use_veto && IS_VETO_PATH(cnum, n)) continue;
|
||||
if (use_veto && conn && IS_VETO_PATH(conn, n)) continue;
|
||||
|
||||
if (used + l > dirp->mallocsize) {
|
||||
int s = MAX(used+l,used+2000);
|
||||
|
@ -197,8 +197,8 @@ Error was %s.\n", unixname, strerror(errno) ));
|
||||
ubi_slAddHead( &groupname_map_list, (ubi_slNode *)new_ep);
|
||||
}
|
||||
|
||||
DEBUG(10,("load_groupname_map: Added %d entries to groupname map.\n",
|
||||
ubi_slCount( &groupname_map_list ) ));
|
||||
DEBUG(10,("load_groupname_map: Added %ld entries to groupname map.\n",
|
||||
ubi_slCount(&groupname_map_list)));
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
@ -37,7 +37,6 @@
|
||||
extern int DEBUGLEVEL;
|
||||
extern int max_send;
|
||||
extern files_struct Files[];
|
||||
extern connection_struct Connections[];
|
||||
|
||||
extern fstring local_machine;
|
||||
extern fstring global_myworkgroup;
|
||||
@ -65,31 +64,32 @@ extern int Client;
|
||||
extern int oplock_sock;
|
||||
extern int smb_read_error;
|
||||
|
||||
static BOOL api_Unsupported(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len);
|
||||
static BOOL api_TooSmall(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len);
|
||||
|
||||
|
||||
static int CopyExpanded(int cnum, int snum, char** dst, char* src, int* n)
|
||||
static int CopyExpanded(connection_struct *conn,
|
||||
int snum, char** dst, char* src, int* n)
|
||||
{
|
||||
pstring buf;
|
||||
int l;
|
||||
pstring buf;
|
||||
int l;
|
||||
|
||||
if (!src || !dst || !n || !(*dst)) return(0);
|
||||
if (!src || !dst || !n || !(*dst)) return(0);
|
||||
|
||||
StrnCpy(buf,src,sizeof(buf)/2);
|
||||
string_sub(buf,"%S",lp_servicename(snum));
|
||||
standard_sub(cnum,buf);
|
||||
StrnCpy(*dst,buf,*n);
|
||||
l = strlen(*dst) + 1;
|
||||
(*dst) += l;
|
||||
(*n) -= l;
|
||||
return l;
|
||||
StrnCpy(buf,src,sizeof(buf)/2);
|
||||
string_sub(buf,"%S",lp_servicename(snum));
|
||||
standard_sub(conn,buf);
|
||||
StrnCpy(*dst,buf,*n);
|
||||
l = strlen(*dst) + 1;
|
||||
(*dst) += l;
|
||||
(*n) -= l;
|
||||
return l;
|
||||
}
|
||||
|
||||
static int CopyAndAdvance(char** dst, char* src, int* n)
|
||||
@ -103,24 +103,24 @@ static int CopyAndAdvance(char** dst, char* src, int* n)
|
||||
return l;
|
||||
}
|
||||
|
||||
static int StrlenExpanded(int cnum, int snum, char* s)
|
||||
static int StrlenExpanded(connection_struct *conn, int snum, char* s)
|
||||
{
|
||||
pstring buf;
|
||||
if (!s) return(0);
|
||||
StrnCpy(buf,s,sizeof(buf)/2);
|
||||
string_sub(buf,"%S",lp_servicename(snum));
|
||||
standard_sub(cnum,buf);
|
||||
return strlen(buf) + 1;
|
||||
pstring buf;
|
||||
if (!s) return(0);
|
||||
StrnCpy(buf,s,sizeof(buf)/2);
|
||||
string_sub(buf,"%S",lp_servicename(snum));
|
||||
standard_sub(conn,buf);
|
||||
return strlen(buf) + 1;
|
||||
}
|
||||
|
||||
static char* Expand(int cnum, int snum, char* s)
|
||||
static char* Expand(connection_struct *conn, int snum, char* s)
|
||||
{
|
||||
static pstring buf;
|
||||
if (!s) return(NULL);
|
||||
StrnCpy(buf,s,sizeof(buf)/2);
|
||||
string_sub(buf,"%S",lp_servicename(snum));
|
||||
standard_sub(cnum,buf);
|
||||
return &buf[0];
|
||||
static pstring buf;
|
||||
if (!s) return(NULL);
|
||||
StrnCpy(buf,s,sizeof(buf)/2);
|
||||
string_sub(buf,"%S",lp_servicename(snum));
|
||||
standard_sub(conn,buf);
|
||||
return &buf[0];
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -530,7 +530,7 @@ static int check_printq_info(struct pack_desc* desc,
|
||||
return True;
|
||||
}
|
||||
|
||||
static void fill_printjob_info(int cnum, int snum, int uLevel,
|
||||
static void fill_printjob_info(connection_struct *conn, int snum, int uLevel,
|
||||
struct pack_desc* desc,
|
||||
print_queue_struct* queue, int n)
|
||||
{
|
||||
@ -577,7 +577,7 @@ static void fill_printjob_info(int cnum, int snum, int uLevel,
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_printq_info(int cnum, int snum, int uLevel,
|
||||
static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
|
||||
struct pack_desc* desc,
|
||||
int count, print_queue_struct* queue,
|
||||
print_status_struct* status)
|
||||
@ -590,7 +590,7 @@ static void fill_printq_info(int cnum, int snum, int uLevel,
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
PACKS(desc,"z",Expand(cnum,snum,SERVICE(snum)));
|
||||
PACKS(desc,"z",Expand(conn,snum,SERVICE(snum)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ static void fill_printq_info(int cnum, int snum, int uLevel,
|
||||
PACKI(desc,"W",LPSTAT_ERROR);
|
||||
}
|
||||
else if (!status || !status->message[0]) {
|
||||
PACKS(desc,"z",Expand(cnum,snum,lp_comment(snum)));
|
||||
PACKS(desc,"z",Expand(conn,snum,lp_comment(snum)));
|
||||
PACKI(desc,"W",LPSTAT_OK); /* status */
|
||||
} else {
|
||||
PACKS(desc,"z",status->message);
|
||||
@ -625,7 +625,7 @@ static void fill_printq_info(int cnum, int snum, int uLevel,
|
||||
PACKS(desc,"z","WinPrint"); /* pszPrProc */
|
||||
PACKS(desc,"z",""); /* pszParms */
|
||||
if (!status || !status->message[0]) {
|
||||
PACKS(desc,"z",Expand(cnum,snum,lp_comment(snum))); /* pszComment */
|
||||
PACKS(desc,"z",Expand(conn,snum,lp_comment(snum))); /* pszComment */
|
||||
PACKI(desc,"W",LPSTAT_OK); /* fsStatus */
|
||||
} else {
|
||||
PACKS(desc,"z",status->message); /* pszComment */
|
||||
@ -639,7 +639,7 @@ static void fill_printq_info(int cnum, int snum, int uLevel,
|
||||
if (uLevel == 2 || uLevel == 4) {
|
||||
int i;
|
||||
for (i=0;i<count;i++)
|
||||
fill_printjob_info(cnum,snum,uLevel == 2 ? 1 : 2,desc,&queue[i],i);
|
||||
fill_printjob_info(conn,snum,uLevel == 2 ? 1 : 2,desc,&queue[i],i);
|
||||
}
|
||||
|
||||
if (uLevel==52) {
|
||||
@ -788,7 +788,8 @@ int get_printerdrivernumber(int snum)
|
||||
return(i);
|
||||
}
|
||||
|
||||
static BOOL api_DosPrintQGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_DosPrintQGetInfo(connection_struct *conn,
|
||||
uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -837,16 +838,16 @@ static BOOL api_DosPrintQGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
{
|
||||
count = get_printerdrivernumber(snum);
|
||||
DEBUG(3,("api_DosPrintQGetInfo: Driver files count: %d\n",count));
|
||||
} else {
|
||||
count = get_printqueue(SNUM(conn), conn,&queue,&status);
|
||||
}
|
||||
else
|
||||
count = get_printqueue(snum,cnum,&queue,&status);
|
||||
|
||||
if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
|
||||
desc.base = *rdata;
|
||||
desc.buflen = mdrcnt;
|
||||
if (init_package(&desc,1,count)) {
|
||||
desc.subcount = count;
|
||||
fill_printq_info(cnum,snum,uLevel,&desc,count,queue,&status);
|
||||
fill_printq_info(conn,snum,uLevel,&desc,count,queue,&status);
|
||||
}
|
||||
|
||||
*rdata_len = desc.usedlen;
|
||||
@ -868,7 +869,7 @@ static BOOL api_DosPrintQGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
view list of all print jobs on all queues
|
||||
****************************************************************************/
|
||||
static BOOL api_DosPrintQEnum(int cnum, uint16 vuid, char* param, char* data,
|
||||
static BOOL api_DosPrintQEnum(connection_struct *conn, uint16 vuid, char* param, char* data,
|
||||
int mdrcnt, int mprcnt,
|
||||
char **rdata, char** rparam,
|
||||
int *rdata_len, int *rparam_len)
|
||||
@ -907,7 +908,7 @@ static BOOL api_DosPrintQEnum(int cnum, uint16 vuid, char* param, char* data,
|
||||
n = 0;
|
||||
for (i = 0; i < services; i++)
|
||||
if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
|
||||
subcntarr[n] = get_printqueue(i,cnum,&queue[n],&status[n]);
|
||||
subcntarr[n] = get_printqueue(i, conn,&queue[n],&status[n]);
|
||||
subcnt += subcntarr[n];
|
||||
n++;
|
||||
}
|
||||
@ -921,7 +922,7 @@ static BOOL api_DosPrintQEnum(int cnum, uint16 vuid, char* param, char* data,
|
||||
succnt = 0;
|
||||
for (i = 0; i < services; i++)
|
||||
if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
|
||||
fill_printq_info(cnum,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
|
||||
fill_printq_info(conn,i,uLevel,&desc,subcntarr[n],queue[n],&status[n]);
|
||||
n++;
|
||||
if (desc.errcode == NERR_Success) succnt = n;
|
||||
}
|
||||
@ -1180,7 +1181,7 @@ static BOOL srv_comp(struct srv_info_struct *s1,struct srv_info_struct *s2)
|
||||
view list of servers available (or possibly domains). The info is
|
||||
extracted from lists saved by nmbd on the local host
|
||||
****************************************************************************/
|
||||
static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
|
||||
static BOOL api_RNetServerEnum(connection_struct *conn, uint16 vuid, char *param, char *data,
|
||||
int mdrcnt, int mprcnt, char **rdata,
|
||||
char **rparam, int *rdata_len, int *rparam_len)
|
||||
{
|
||||
@ -1306,7 +1307,7 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
|
||||
/****************************************************************************
|
||||
command 0x34 - suspected of being a "Lookup Names" stub api
|
||||
****************************************************************************/
|
||||
static BOOL api_RNetGroupGetUsers(int cnum, uint16 vuid, char *param, char *data,
|
||||
static BOOL api_RNetGroupGetUsers(connection_struct *conn, uint16 vuid, char *param, char *data,
|
||||
int mdrcnt, int mprcnt, char **rdata,
|
||||
char **rparam, int *rdata_len, int *rparam_len)
|
||||
{
|
||||
@ -1360,7 +1361,7 @@ static BOOL check_share_info(int uLevel, char* id)
|
||||
return True;
|
||||
}
|
||||
|
||||
static int fill_share_info(int cnum, int snum, int uLevel,
|
||||
static int fill_share_info(connection_struct *conn, int snum, int uLevel,
|
||||
char** buf, int* buflen,
|
||||
char** stringbuf, int* stringspace, char* baseaddr)
|
||||
{
|
||||
@ -1382,7 +1383,7 @@ static int fill_share_info(int cnum, int snum, int uLevel,
|
||||
if (!buf)
|
||||
{
|
||||
len = 0;
|
||||
if (uLevel > 0) len += StrlenExpanded(cnum,snum,lp_comment(snum));
|
||||
if (uLevel > 0) len += StrlenExpanded(conn,snum,lp_comment(snum));
|
||||
if (uLevel > 1) len += strlen(lp_pathname(snum)) + 1;
|
||||
if (buflen) *buflen = struct_len;
|
||||
if (stringspace) *stringspace = len;
|
||||
@ -1415,7 +1416,7 @@ static int fill_share_info(int cnum, int snum, int uLevel,
|
||||
if (strequal("IPC$",lp_servicename(snum))) type = STYPE_IPC;
|
||||
SSVAL(p,14,type); /* device type */
|
||||
SIVAL(p,16,PTR_DIFF(p2,baseaddr));
|
||||
len += CopyExpanded(cnum,snum,&p2,lp_comment(snum),&l2);
|
||||
len += CopyExpanded(conn,snum,&p2,lp_comment(snum),&l2);
|
||||
}
|
||||
|
||||
if (uLevel > 1)
|
||||
@ -1455,7 +1456,7 @@ static int fill_share_info(int cnum, int snum, int uLevel,
|
||||
return len;
|
||||
}
|
||||
|
||||
static BOOL api_RNetShareGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1475,7 +1476,7 @@ static BOOL api_RNetShareGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
|
||||
*rdata = REALLOC(*rdata,mdrcnt);
|
||||
p = *rdata;
|
||||
*rdata_len = fill_share_info(cnum,snum,uLevel,&p,&mdrcnt,0,0,0);
|
||||
*rdata_len = fill_share_info(conn,snum,uLevel,&p,&mdrcnt,0,0,0);
|
||||
if (*rdata_len < 0) return False;
|
||||
|
||||
*rparam_len = 6;
|
||||
@ -1490,7 +1491,7 @@ static BOOL api_RNetShareGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
view list of shares available
|
||||
****************************************************************************/
|
||||
static BOOL api_RNetShareEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_RNetShareEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1516,7 +1517,7 @@ static BOOL api_RNetShareEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
if (lp_browseable(i) && lp_snum_ok(i))
|
||||
{
|
||||
total++;
|
||||
data_len += fill_share_info(cnum,i,uLevel,0,&f_len,0,&s_len,0);
|
||||
data_len += fill_share_info(conn,i,uLevel,0,&f_len,0,&s_len,0);
|
||||
if (data_len <= buf_len)
|
||||
{
|
||||
counted++;
|
||||
@ -1536,7 +1537,7 @@ static BOOL api_RNetShareEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
s_len = string_len;
|
||||
for (i = 0; i < count;i++)
|
||||
if (lp_browseable(i) && lp_snum_ok(i))
|
||||
if (fill_share_info(cnum,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0)
|
||||
if (fill_share_info(conn,i,uLevel,&p,&f_len,&p2,&s_len,*rdata) < 0)
|
||||
break;
|
||||
|
||||
*rparam_len = 8;
|
||||
@ -1557,7 +1558,7 @@ static BOOL api_RNetShareEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
get the time of day info
|
||||
****************************************************************************/
|
||||
static BOOL api_NetRemoteTOD(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_NetRemoteTOD(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1606,7 +1607,7 @@ static BOOL api_NetRemoteTOD(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
set the user password
|
||||
****************************************************************************/
|
||||
static BOOL api_SetUserPassword(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_SetUserPassword(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1682,7 +1683,7 @@ static BOOL api_SetUserPassword(int cnum,uint16 vuid, char *param,char *data,
|
||||
Set the user password (SamOEM version - gets plaintext).
|
||||
****************************************************************************/
|
||||
|
||||
static BOOL api_SamOEMChangePassword(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_SamOEMChangePassword(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1760,7 +1761,7 @@ static BOOL api_SamOEMChangePassword(int cnum,uint16 vuid, char *param,char *dat
|
||||
delete a print job
|
||||
Form: <W> <>
|
||||
****************************************************************************/
|
||||
static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1789,7 +1790,7 @@ static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
|
||||
{
|
||||
print_queue_struct *queue=NULL;
|
||||
lpq_reset(snum);
|
||||
count = get_printqueue(snum,cnum,&queue,NULL);
|
||||
count = get_printqueue(snum,conn,&queue,NULL);
|
||||
|
||||
for (i=0;i<count;i++)
|
||||
if ((queue[i].job&0xFF) == jobid)
|
||||
@ -1797,13 +1798,13 @@ static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
|
||||
switch (function) {
|
||||
case 81: /* delete */
|
||||
DEBUG(3,("Deleting queue entry %d\n",queue[i].job));
|
||||
del_printqueue(cnum,snum,queue[i].job);
|
||||
del_printqueue(conn,snum,queue[i].job);
|
||||
break;
|
||||
case 82: /* pause */
|
||||
case 83: /* resume */
|
||||
DEBUG(3,("%s queue entry %d\n",
|
||||
(function==82?"pausing":"resuming"),queue[i].job));
|
||||
status_printjob(cnum,snum,queue[i].job,
|
||||
status_printjob(conn,snum,queue[i].job,
|
||||
(function==82?LPQ_PAUSED:LPQ_QUEUED));
|
||||
break;
|
||||
}
|
||||
@ -1824,7 +1825,7 @@ static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
Purge a print queue - or pause or resume it.
|
||||
****************************************************************************/
|
||||
static BOOL api_WPrintQueuePurge(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintQueuePurge(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1862,7 +1863,7 @@ static BOOL api_WPrintQueuePurge(int cnum,uint16 vuid, char *param,char *data,
|
||||
switch (function) {
|
||||
case 74: /* Pause queue */
|
||||
case 75: /* Resume queue */
|
||||
status_printqueue(cnum,snum,(function==74?LPSTAT_STOPPED:LPSTAT_OK));
|
||||
status_printqueue(conn,snum,(function==74?LPSTAT_STOPPED:LPSTAT_OK));
|
||||
DEBUG(3,("Print queue %s, queue=%s\n",
|
||||
(function==74?"pause":"resume"),QueueName));
|
||||
break;
|
||||
@ -1870,9 +1871,9 @@ static BOOL api_WPrintQueuePurge(int cnum,uint16 vuid, char *param,char *data,
|
||||
{
|
||||
print_queue_struct *queue=NULL;
|
||||
int i, count;
|
||||
count = get_printqueue(snum,cnum,&queue,NULL);
|
||||
count = get_printqueue(snum,conn,&queue,NULL);
|
||||
for (i = 0; i < count; i++)
|
||||
del_printqueue(cnum,snum,queue[i].job);
|
||||
del_printqueue(conn,snum,queue[i].job);
|
||||
|
||||
if (queue) free(queue);
|
||||
DEBUG(3,("Print queue purge, queue=%s\n",QueueName));
|
||||
@ -1907,7 +1908,7 @@ static int check_printjob_info(struct pack_desc* desc,
|
||||
return True;
|
||||
}
|
||||
|
||||
static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
|
||||
static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -1941,7 +1942,7 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
|
||||
int count;
|
||||
|
||||
lpq_reset(snum);
|
||||
count = get_printqueue(snum,cnum,&queue,NULL);
|
||||
count = get_printqueue(snum,conn,&queue,NULL);
|
||||
for (i=0;i<count;i++) /* find job */
|
||||
if ((queue[i].job&0xFF) == jobid) break;
|
||||
|
||||
@ -1987,16 +1988,17 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
|
||||
if (Files[i].open && Files[i].print_file)
|
||||
{
|
||||
pstring wd;
|
||||
int fcnum = Files[i].cnum;
|
||||
connection_struct *fconn = Files[i].conn;
|
||||
GetWd(wd);
|
||||
unbecome_user();
|
||||
|
||||
if (!become_user(&Connections[fcnum], fcnum,vuid) ||
|
||||
!become_service(fcnum,True))
|
||||
if (!become_user(fconn,vuid) ||
|
||||
!become_service(fconn,True))
|
||||
break;
|
||||
|
||||
if (sys_rename(Files[i].name,name) == 0)
|
||||
string_set(&Files[i].name,name);
|
||||
if (sys_rename(Files[i].fsp_name,name) == 0) {
|
||||
string_set(&Files[i].fsp_name,name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2019,7 +2021,7 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
|
||||
/****************************************************************************
|
||||
get info about the server
|
||||
****************************************************************************/
|
||||
static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_RNetServerGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2102,7 +2104,7 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
SIVAL(p,6,0);
|
||||
} else {
|
||||
SIVAL(p,6,PTR_DIFF(p2,*rdata));
|
||||
standard_sub(cnum,comment);
|
||||
standard_sub(conn,comment);
|
||||
StrnCpy(p2,comment,MAX(mdrcnt - struct_len,0));
|
||||
p2 = skip_string(p2,1);
|
||||
}
|
||||
@ -2127,7 +2129,7 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
get info about the server
|
||||
****************************************************************************/
|
||||
static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_NetWkstaGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2364,7 +2366,7 @@ There is no auxiliary data in the response.
|
||||
#define AF_OP_ACCOUNTS 3
|
||||
|
||||
|
||||
static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2437,7 +2439,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
|
||||
if (uLevel == 11) /* modelled after NTAS 3.51 reply */
|
||||
{
|
||||
SSVAL(p,usri11_priv,Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
SSVAL(p,usri11_priv,conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
SIVAL(p,usri11_auth_flags,AF_OP_PRINT); /* auth flags */
|
||||
SIVALS(p,usri11_password_age,-1); /* password age */
|
||||
SIVAL(p,usri11_homedir,PTR_DIFF(p2,p)); /* home dir */
|
||||
@ -2475,7 +2477,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
memset(p+22,' ',16); /* password */
|
||||
SIVALS(p,38,-1); /* password age */
|
||||
SSVAL(p,42,
|
||||
Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */
|
||||
pstrcpy(p2,lp_logon_path());
|
||||
p2 = skip_string(p2,1);
|
||||
@ -2523,7 +2525,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
/*******************************************************************
|
||||
get groups that a user is a member of
|
||||
******************************************************************/
|
||||
static BOOL api_NetUserGetGroups(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2570,7 +2572,7 @@ static BOOL api_NetUserGetGroups(int cnum,uint16 vuid, char *param,char *data,
|
||||
}
|
||||
|
||||
|
||||
static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WWkstaUserLogon(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2605,7 +2607,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
|
||||
PACKS(&desc,"B21",name); /* eff. name */
|
||||
PACKS(&desc,"B",""); /* pad */
|
||||
PACKI(&desc,"W",
|
||||
Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
conn->admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
|
||||
PACKI(&desc,"D",0); /* auth flags XXX */
|
||||
PACKI(&desc,"W",0); /* num logons */
|
||||
PACKI(&desc,"W",0); /* bad pw count */
|
||||
@ -2628,7 +2630,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
|
||||
/* JHT - By calling lp_logon_script() and standard_sub() we have */
|
||||
/* made sure all macros are fully substituted and available */
|
||||
logon_script = lp_logon_script();
|
||||
standard_sub( cnum, logon_script );
|
||||
standard_sub( conn, logon_script );
|
||||
PACKS(&desc,"z", logon_script); /* script path */
|
||||
/* End of JHT mods */
|
||||
|
||||
@ -2650,7 +2652,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
api_WAccessGetUserPerms
|
||||
****************************************************************************/
|
||||
static BOOL api_WAccessGetUserPerms(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WAccessGetUserPerms(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2678,7 +2680,7 @@ static BOOL api_WAccessGetUserPerms(int cnum,uint16 vuid, char *param,char *data
|
||||
/****************************************************************************
|
||||
api_WPrintJobEnumerate
|
||||
****************************************************************************/
|
||||
static BOOL api_WPrintJobGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintJobGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2711,7 +2713,7 @@ static BOOL api_WPrintJobGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
|
||||
if (snum < 0 || !VALID_SNUM(snum)) return(False);
|
||||
|
||||
count = get_printqueue(snum,cnum,&queue,&status);
|
||||
count = get_printqueue(snum,conn,&queue,&status);
|
||||
for (i = 0; i < count; i++) {
|
||||
if ((queue[i].job & 0xFF) == job) break;
|
||||
}
|
||||
@ -2721,7 +2723,7 @@ static BOOL api_WPrintJobGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
|
||||
if (init_package(&desc,1,0)) {
|
||||
if (i < count) {
|
||||
fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
|
||||
fill_printjob_info(conn,snum,uLevel,&desc,&queue[i],i);
|
||||
*rdata_len = desc.usedlen;
|
||||
}
|
||||
else {
|
||||
@ -2742,7 +2744,7 @@ static BOOL api_WPrintJobGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
return(True);
|
||||
}
|
||||
|
||||
static BOOL api_WPrintJobEnumerate(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintJobEnumerate(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2784,7 +2786,7 @@ static BOOL api_WPrintJobEnumerate(int cnum,uint16 vuid, char *param,char *data,
|
||||
|
||||
if (snum < 0 || !VALID_SNUM(snum)) return(False);
|
||||
|
||||
count = get_printqueue(snum,cnum,&queue,&status);
|
||||
count = get_printqueue(snum,conn,&queue,&status);
|
||||
if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
|
||||
desc.base = *rdata;
|
||||
desc.buflen = mdrcnt;
|
||||
@ -2792,7 +2794,7 @@ static BOOL api_WPrintJobEnumerate(int cnum,uint16 vuid, char *param,char *data,
|
||||
if (init_package(&desc,count,0)) {
|
||||
succnt = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
fill_printjob_info(cnum,snum,uLevel,&desc,&queue[i],i);
|
||||
fill_printjob_info(conn,snum,uLevel,&desc,&queue[i],i);
|
||||
if (desc.errcode == NERR_Success) succnt = i+1;
|
||||
}
|
||||
}
|
||||
@ -2827,7 +2829,7 @@ static int check_printdest_info(struct pack_desc* desc,
|
||||
return True;
|
||||
}
|
||||
|
||||
static void fill_printdest_info(int cnum, int snum, int uLevel,
|
||||
static void fill_printdest_info(connection_struct *conn, int snum, int uLevel,
|
||||
struct pack_desc* desc)
|
||||
{
|
||||
char buf[100];
|
||||
@ -2860,7 +2862,7 @@ static void fill_printdest_info(int cnum, int snum, int uLevel,
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL api_WPrintDestGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintDestGetInfo(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2904,7 +2906,7 @@ static BOOL api_WPrintDestGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
desc.base = *rdata;
|
||||
desc.buflen = mdrcnt;
|
||||
if (init_package(&desc,1,0)) {
|
||||
fill_printdest_info(cnum,snum,uLevel,&desc);
|
||||
fill_printdest_info(conn,snum,uLevel,&desc);
|
||||
}
|
||||
*rdata_len = desc.usedlen;
|
||||
}
|
||||
@ -2919,7 +2921,7 @@ static BOOL api_WPrintDestGetInfo(int cnum,uint16 vuid, char *param,char *data,
|
||||
return(True);
|
||||
}
|
||||
|
||||
static BOOL api_WPrintDestEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintDestEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -2957,7 +2959,7 @@ static BOOL api_WPrintDestEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
n = 0;
|
||||
for (i = 0; i < services; i++) {
|
||||
if (lp_snum_ok(i) && lp_print_ok(i) && lp_browseable(i)) {
|
||||
fill_printdest_info(cnum,i,uLevel,&desc);
|
||||
fill_printdest_info(conn,i,uLevel,&desc);
|
||||
n++;
|
||||
if (desc.errcode == NERR_Success) succnt = n;
|
||||
}
|
||||
@ -2977,7 +2979,7 @@ static BOOL api_WPrintDestEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
return(True);
|
||||
}
|
||||
|
||||
static BOOL api_WPrintDriverEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintDriverEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -3022,7 +3024,7 @@ static BOOL api_WPrintDriverEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
return(True);
|
||||
}
|
||||
|
||||
static BOOL api_WPrintQProcEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintQProcEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -3068,7 +3070,7 @@ static BOOL api_WPrintQProcEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
return(True);
|
||||
}
|
||||
|
||||
static BOOL api_WPrintPortEnum(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_WPrintPortEnum(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -3366,7 +3368,7 @@ static BOOL api_no_reply(char *outbuf, int max_rdata_len)
|
||||
/****************************************************************************
|
||||
handle remote api calls delivered to a named pipe already opened.
|
||||
****************************************************************************/
|
||||
static int api_fd_reply(int cnum,uint16 vuid,char *outbuf,
|
||||
static int api_fd_reply(connection_struct *conn,uint16 vuid,char *outbuf,
|
||||
uint16 *setup,char *data,char *params,
|
||||
int suwcnt,int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
|
||||
{
|
||||
@ -3407,8 +3409,6 @@ static int api_fd_reply(int cnum,uint16 vuid,char *outbuf,
|
||||
{
|
||||
DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)",
|
||||
subcommand, p->name, pnum));
|
||||
DEBUG(3,("(tdscnt=%d,tpscnt=%d,mdrcnt=%d,mprcnt=%d,cnum=%d,vuid=%d)\n",
|
||||
tdscnt,tpscnt,mdrcnt,mprcnt,cnum,vuid));
|
||||
|
||||
/* record maximum data length that can be transmitted in an SMBtrans */
|
||||
p->file_offset = mdrcnt;
|
||||
@ -3447,7 +3447,7 @@ static int api_fd_reply(int cnum,uint16 vuid,char *outbuf,
|
||||
/****************************************************************************
|
||||
the buffer was too small
|
||||
****************************************************************************/
|
||||
static BOOL api_TooSmall(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_TooSmall(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -3468,7 +3468,7 @@ static BOOL api_TooSmall(int cnum,uint16 vuid, char *param,char *data,
|
||||
/****************************************************************************
|
||||
the request is not supported
|
||||
****************************************************************************/
|
||||
static BOOL api_Unsupported(int cnum,uint16 vuid, char *param,char *data,
|
||||
static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,char *data,
|
||||
int mdrcnt,int mprcnt,
|
||||
char **rdata,char **rparam,
|
||||
int *rdata_len,int *rparam_len)
|
||||
@ -3493,7 +3493,8 @@ struct
|
||||
{
|
||||
char *name;
|
||||
int id;
|
||||
BOOL (*fn)(int,uint16,char *,char *,int,int,char **,char **,int *,int *);
|
||||
BOOL (*fn)(connection_struct *,uint16,char *,char *,
|
||||
int,int,char **,char **,int *,int *);
|
||||
int flags;
|
||||
} api_commands[] = {
|
||||
{"RNetShareEnum", 0, api_RNetShareEnum,0},
|
||||
@ -3531,7 +3532,7 @@ struct
|
||||
/****************************************************************************
|
||||
handle remote api calls
|
||||
****************************************************************************/
|
||||
static int api_reply(int cnum,uint16 vuid,char *outbuf,char *data,char *params,
|
||||
static int api_reply(connection_struct *conn,uint16 vuid,char *outbuf,char *data,char *params,
|
||||
int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
|
||||
{
|
||||
int api_command = SVAL(params,0);
|
||||
@ -3558,21 +3559,21 @@ static int api_reply(int cnum,uint16 vuid,char *outbuf,char *data,char *params,
|
||||
rdata = (char *)malloc(1024); if (rdata) bzero(rdata,1024);
|
||||
rparam = (char *)malloc(1024); if (rparam) bzero(rparam,1024);
|
||||
|
||||
reply = api_commands[i].fn(cnum,vuid,params,data,mdrcnt,mprcnt,
|
||||
reply = api_commands[i].fn(conn,vuid,params,data,mdrcnt,mprcnt,
|
||||
&rdata,&rparam,&rdata_len,&rparam_len);
|
||||
|
||||
|
||||
if (rdata_len > mdrcnt ||
|
||||
rparam_len > mprcnt)
|
||||
{
|
||||
reply = api_TooSmall(cnum,vuid,params,data,mdrcnt,mprcnt,
|
||||
reply = api_TooSmall(conn,vuid,params,data,mdrcnt,mprcnt,
|
||||
&rdata,&rparam,&rdata_len,&rparam_len);
|
||||
}
|
||||
|
||||
|
||||
/* if we get False back then it's actually unsupported */
|
||||
if (!reply)
|
||||
api_Unsupported(cnum,vuid,params,data,mdrcnt,mprcnt,
|
||||
api_Unsupported(conn,vuid,params,data,mdrcnt,mprcnt,
|
||||
&rdata,&rparam,&rdata_len,&rparam_len);
|
||||
|
||||
|
||||
@ -3597,7 +3598,7 @@ static int api_reply(int cnum,uint16 vuid,char *outbuf,char *data,char *params,
|
||||
/****************************************************************************
|
||||
handle named pipe commands
|
||||
****************************************************************************/
|
||||
static int named_pipe(int cnum,uint16 vuid, char *outbuf,char *name,
|
||||
static int named_pipe(connection_struct *conn,uint16 vuid, char *outbuf,char *name,
|
||||
uint16 *setup,char *data,char *params,
|
||||
int suwcnt,int tdscnt,int tpscnt,
|
||||
int msrcnt,int mdrcnt,int mprcnt)
|
||||
@ -3606,12 +3607,12 @@ static int named_pipe(int cnum,uint16 vuid, char *outbuf,char *name,
|
||||
|
||||
if (strequal(name,"LANMAN"))
|
||||
{
|
||||
return api_reply(cnum,vuid,outbuf,data,params,tdscnt,tpscnt,mdrcnt,mprcnt);
|
||||
return api_reply(conn,vuid,outbuf,data,params,tdscnt,tpscnt,mdrcnt,mprcnt);
|
||||
}
|
||||
|
||||
if (strlen(name) < 1)
|
||||
{
|
||||
return api_fd_reply(cnum,vuid,outbuf,setup,data,params,suwcnt,tdscnt,tpscnt,mdrcnt,mprcnt);
|
||||
return api_fd_reply(conn,vuid,outbuf,setup,data,params,suwcnt,tdscnt,tpscnt,mdrcnt,mprcnt);
|
||||
}
|
||||
|
||||
if (setup)
|
||||
@ -3626,141 +3627,132 @@ static int named_pipe(int cnum,uint16 vuid, char *outbuf,char *name,
|
||||
/****************************************************************************
|
||||
reply to a SMBtrans
|
||||
****************************************************************************/
|
||||
int reply_trans(char *inbuf,char *outbuf, int size, int bufsize)
|
||||
int reply_trans(connection_struct *conn, char *inbuf,char *outbuf, int size, int bufsize)
|
||||
{
|
||||
fstring name;
|
||||
fstring name;
|
||||
|
||||
char *data=NULL,*params=NULL;
|
||||
uint16 *setup=NULL;
|
||||
char *data=NULL,*params=NULL;
|
||||
uint16 *setup=NULL;
|
||||
int outsize = 0;
|
||||
uint16 vuid = SVAL(inbuf,smb_uid);
|
||||
int tpscnt = SVAL(inbuf,smb_vwv0);
|
||||
int tdscnt = SVAL(inbuf,smb_vwv1);
|
||||
int mprcnt = SVAL(inbuf,smb_vwv2);
|
||||
int mdrcnt = SVAL(inbuf,smb_vwv3);
|
||||
int msrcnt = CVAL(inbuf,smb_vwv4);
|
||||
BOOL close_on_completion = BITSETW(inbuf+smb_vwv5,0);
|
||||
BOOL one_way = BITSETW(inbuf+smb_vwv5,1);
|
||||
int pscnt = SVAL(inbuf,smb_vwv9);
|
||||
int psoff = SVAL(inbuf,smb_vwv10);
|
||||
int dscnt = SVAL(inbuf,smb_vwv11);
|
||||
int dsoff = SVAL(inbuf,smb_vwv12);
|
||||
int suwcnt = CVAL(inbuf,smb_vwv13);
|
||||
|
||||
int outsize = 0;
|
||||
int cnum = SVAL(inbuf,smb_tid);
|
||||
uint16 vuid = SVAL(inbuf,smb_uid);
|
||||
bzero(name, sizeof(name));
|
||||
fstrcpy(name,smb_buf(inbuf));
|
||||
|
||||
int tpscnt = SVAL(inbuf,smb_vwv0);
|
||||
int tdscnt = SVAL(inbuf,smb_vwv1);
|
||||
int mprcnt = SVAL(inbuf,smb_vwv2);
|
||||
int mdrcnt = SVAL(inbuf,smb_vwv3);
|
||||
int msrcnt = CVAL(inbuf,smb_vwv4);
|
||||
BOOL close_on_completion = BITSETW(inbuf+smb_vwv5,0);
|
||||
BOOL one_way = BITSETW(inbuf+smb_vwv5,1);
|
||||
int pscnt = SVAL(inbuf,smb_vwv9);
|
||||
int psoff = SVAL(inbuf,smb_vwv10);
|
||||
int dscnt = SVAL(inbuf,smb_vwv11);
|
||||
int dsoff = SVAL(inbuf,smb_vwv12);
|
||||
int suwcnt = CVAL(inbuf,smb_vwv13);
|
||||
|
||||
bzero(name, sizeof(name));
|
||||
fstrcpy(name,smb_buf(inbuf));
|
||||
|
||||
if (dscnt > tdscnt || pscnt > tpscnt) {
|
||||
exit_server("invalid trans parameters\n");
|
||||
}
|
||||
if (dscnt > tdscnt || pscnt > tpscnt) {
|
||||
exit_server("invalid trans parameters\n");
|
||||
}
|
||||
|
||||
if (tdscnt)
|
||||
{
|
||||
data = (char *)malloc(tdscnt);
|
||||
memcpy(data,smb_base(inbuf)+dsoff,dscnt);
|
||||
}
|
||||
if (tpscnt)
|
||||
{
|
||||
params = (char *)malloc(tpscnt);
|
||||
memcpy(params,smb_base(inbuf)+psoff,pscnt);
|
||||
}
|
||||
if (tdscnt) {
|
||||
data = (char *)malloc(tdscnt);
|
||||
memcpy(data,smb_base(inbuf)+dsoff,dscnt);
|
||||
}
|
||||
|
||||
if (suwcnt)
|
||||
{
|
||||
int i;
|
||||
setup = (uint16 *)malloc(suwcnt*sizeof(setup[0]));
|
||||
for (i=0;i<suwcnt;i++)
|
||||
setup[i] = SVAL(inbuf,smb_vwv14+i*SIZEOFWORD);
|
||||
}
|
||||
if (tpscnt) {
|
||||
params = (char *)malloc(tpscnt);
|
||||
memcpy(params,smb_base(inbuf)+psoff,pscnt);
|
||||
}
|
||||
|
||||
if (suwcnt) {
|
||||
int i;
|
||||
setup = (uint16 *)malloc(suwcnt*sizeof(setup[0]));
|
||||
for (i=0;i<suwcnt;i++)
|
||||
setup[i] = SVAL(inbuf,smb_vwv14+i*SIZEOFWORD);
|
||||
}
|
||||
|
||||
|
||||
if (pscnt < tpscnt || dscnt < tdscnt)
|
||||
{
|
||||
/* We need to send an interim response then receive the rest
|
||||
of the parameter/data bytes */
|
||||
outsize = set_message(outbuf,0,0,True);
|
||||
show_msg(outbuf);
|
||||
send_smb(Client,outbuf);
|
||||
}
|
||||
if (pscnt < tpscnt || dscnt < tdscnt) {
|
||||
/* We need to send an interim response then receive the rest
|
||||
of the parameter/data bytes */
|
||||
outsize = set_message(outbuf,0,0,True);
|
||||
show_msg(outbuf);
|
||||
send_smb(Client,outbuf);
|
||||
}
|
||||
|
||||
/* receive the rest of the trans packet */
|
||||
while (pscnt < tpscnt || dscnt < tdscnt)
|
||||
{
|
||||
BOOL ret;
|
||||
int pcnt,poff,dcnt,doff,pdisp,ddisp;
|
||||
/* receive the rest of the trans packet */
|
||||
while (pscnt < tpscnt || dscnt < tdscnt) {
|
||||
BOOL ret;
|
||||
int pcnt,poff,dcnt,doff,pdisp,ddisp;
|
||||
|
||||
ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,SMB_SECONDARY_WAIT);
|
||||
ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,SMB_SECONDARY_WAIT);
|
||||
|
||||
if ((ret && (CVAL(inbuf, smb_com) != SMBtrans)) || !ret) {
|
||||
if(ret) {
|
||||
DEBUG(0,("reply_trans: Invalid secondary trans packet\n"));
|
||||
} else {
|
||||
DEBUG(0,("reply_trans: %s in getting secondary trans response.\n",
|
||||
(smb_read_error == READ_ERROR) ? "error" : "timeout" ));
|
||||
}
|
||||
if (params) free(params);
|
||||
if (data) free(data);
|
||||
if (setup) free(setup);
|
||||
return(ERROR(ERRSRV,ERRerror));
|
||||
}
|
||||
if ((ret && (CVAL(inbuf, smb_com) != SMBtrans)) || !ret) {
|
||||
if(ret) {
|
||||
DEBUG(0,("reply_trans: Invalid secondary trans packet\n"));
|
||||
} else {
|
||||
DEBUG(0,("reply_trans: %s in getting secondary trans response.\n",
|
||||
(smb_read_error == READ_ERROR) ? "error" : "timeout" ));
|
||||
}
|
||||
if (params) free(params);
|
||||
if (data) free(data);
|
||||
if (setup) free(setup);
|
||||
return(ERROR(ERRSRV,ERRerror));
|
||||
}
|
||||
|
||||
show_msg(inbuf);
|
||||
show_msg(inbuf);
|
||||
|
||||
tpscnt = SVAL(inbuf,smb_vwv0);
|
||||
tdscnt = SVAL(inbuf,smb_vwv1);
|
||||
tpscnt = SVAL(inbuf,smb_vwv0);
|
||||
tdscnt = SVAL(inbuf,smb_vwv1);
|
||||
|
||||
pcnt = SVAL(inbuf,smb_vwv2);
|
||||
poff = SVAL(inbuf,smb_vwv3);
|
||||
pdisp = SVAL(inbuf,smb_vwv4);
|
||||
|
||||
dcnt = SVAL(inbuf,smb_vwv5);
|
||||
doff = SVAL(inbuf,smb_vwv6);
|
||||
ddisp = SVAL(inbuf,smb_vwv7);
|
||||
|
||||
pscnt += pcnt;
|
||||
dscnt += dcnt;
|
||||
pcnt = SVAL(inbuf,smb_vwv2);
|
||||
poff = SVAL(inbuf,smb_vwv3);
|
||||
pdisp = SVAL(inbuf,smb_vwv4);
|
||||
|
||||
dcnt = SVAL(inbuf,smb_vwv5);
|
||||
doff = SVAL(inbuf,smb_vwv6);
|
||||
ddisp = SVAL(inbuf,smb_vwv7);
|
||||
|
||||
pscnt += pcnt;
|
||||
dscnt += dcnt;
|
||||
|
||||
if (dscnt > tdscnt || pscnt > tpscnt) {
|
||||
exit_server("invalid trans parameters\n");
|
||||
}
|
||||
|
||||
if (pcnt)
|
||||
memcpy(params+pdisp,smb_base(inbuf)+poff,pcnt);
|
||||
if (dcnt)
|
||||
memcpy(data+ddisp,smb_base(inbuf)+doff,dcnt);
|
||||
}
|
||||
|
||||
|
||||
DEBUG(3,("trans <%s> data=%d params=%d setup=%d\n",
|
||||
name,tdscnt,tpscnt,suwcnt));
|
||||
|
||||
if (strncmp(name,"\\PIPE\\",strlen("\\PIPE\\")) == 0) {
|
||||
DEBUG(5,("calling named_pipe\n"));
|
||||
outsize = named_pipe(conn,vuid,outbuf,name+strlen("\\PIPE\\"),setup,data,params,
|
||||
suwcnt,tdscnt,tpscnt,msrcnt,mdrcnt,mprcnt);
|
||||
} else {
|
||||
DEBUG(3,("invalid pipe name\n"));
|
||||
outsize = 0;
|
||||
}
|
||||
|
||||
if (dscnt > tdscnt || pscnt > tpscnt) {
|
||||
exit_server("invalid trans parameters\n");
|
||||
}
|
||||
|
||||
if (data) free(data);
|
||||
if (params) free(params);
|
||||
if (setup) free(setup);
|
||||
|
||||
if (close_on_completion)
|
||||
close_cnum(conn,vuid);
|
||||
|
||||
if (pcnt)
|
||||
memcpy(params+pdisp,smb_base(inbuf)+poff,pcnt);
|
||||
if (dcnt)
|
||||
memcpy(data+ddisp,smb_base(inbuf)+doff,dcnt);
|
||||
}
|
||||
|
||||
|
||||
DEBUG(3,("trans <%s> data=%d params=%d setup=%d\n",name,tdscnt,tpscnt,suwcnt));
|
||||
|
||||
if (strncmp(name,"\\PIPE\\",strlen("\\PIPE\\")) == 0)
|
||||
{
|
||||
DEBUG(5,("calling named_pipe\n"));
|
||||
outsize = named_pipe(cnum,vuid,outbuf,name+strlen("\\PIPE\\"),setup,data,params,
|
||||
suwcnt,tdscnt,tpscnt,msrcnt,mdrcnt,mprcnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(3,("invalid pipe name\n"));
|
||||
outsize = 0;
|
||||
}
|
||||
|
||||
|
||||
if (data) free(data);
|
||||
if (params) free(params);
|
||||
if (setup) free(setup);
|
||||
|
||||
if (close_on_completion)
|
||||
close_cnum(cnum,vuid);
|
||||
|
||||
if (one_way)
|
||||
return(-1);
|
||||
|
||||
if (outsize == 0)
|
||||
return(ERROR(ERRSRV,ERRnosupport));
|
||||
|
||||
return(outsize);
|
||||
if (one_way)
|
||||
return(-1);
|
||||
|
||||
if (outsize == 0)
|
||||
return(ERROR(ERRSRV,ERRnosupport));
|
||||
|
||||
return(outsize);
|
||||
}
|
||||
|
@ -418,31 +418,6 @@ BOOL is_8_3( char *fname, BOOL check_case )
|
||||
return( True );
|
||||
} /* is_8_3 */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Provide a checksum on a string
|
||||
*
|
||||
* Input: s - the nul-terminated character string for which the checksum
|
||||
* will be calculated.
|
||||
*
|
||||
* Output: The checksum value calculated for s.
|
||||
*
|
||||
* ************************************************************************** **
|
||||
*/
|
||||
int str_checksum( char *s )
|
||||
{
|
||||
int res = 0;
|
||||
int c;
|
||||
int i=0;
|
||||
|
||||
while( *s )
|
||||
{
|
||||
c = *s;
|
||||
res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
|
||||
s++;
|
||||
i++;
|
||||
}
|
||||
return(res);
|
||||
} /* str_checksum */
|
||||
|
||||
/* ************************************************************************** **
|
||||
* Compare two cache keys and return a value indicating their ordinal
|
||||
|
@ -78,7 +78,7 @@ static void msg_deliver(void)
|
||||
string_sub(s,"%s",name);
|
||||
string_sub(s,"%f",msgfrom);
|
||||
string_sub(s,"%t",msgto);
|
||||
standard_sub(-1,s);
|
||||
standard_sub_basic(s);
|
||||
smbrun(s,NULL,False);
|
||||
}
|
||||
|
||||
@ -90,7 +90,8 @@ static void msg_deliver(void)
|
||||
/****************************************************************************
|
||||
reply to a sends
|
||||
****************************************************************************/
|
||||
int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
int reply_sends(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
{
|
||||
int len;
|
||||
char *orig,*dest,*msg;
|
||||
@ -128,7 +129,8 @@ int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
/****************************************************************************
|
||||
reply to a sendstrt
|
||||
****************************************************************************/
|
||||
int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
int reply_sendstrt(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
{
|
||||
char *orig,*dest;
|
||||
int outsize = 0;
|
||||
@ -155,7 +157,8 @@ int reply_sendstrt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
/****************************************************************************
|
||||
reply to a sendtxt
|
||||
****************************************************************************/
|
||||
int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
int reply_sendtxt(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
{
|
||||
int len;
|
||||
int outsize = 0;
|
||||
@ -183,7 +186,8 @@ int reply_sendtxt(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
/****************************************************************************
|
||||
reply to a sendend
|
||||
****************************************************************************/
|
||||
int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
int reply_sendend(connection_struct *conn,
|
||||
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
{
|
||||
int outsize = 0;
|
||||
|
||||
@ -192,7 +196,7 @@ int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
|
||||
|
||||
outsize = set_message(outbuf,0,0,True);
|
||||
|
||||
DEBUG( 3, ( "%s SMBsendend\n" ) );
|
||||
DEBUG(3,("SMBsendend\n"));
|
||||
|
||||
msg_deliver();
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
extern int DEBUGLEVEL;
|
||||
extern int Protocol;
|
||||
extern int chain_fnum;
|
||||
extern connection_struct Connections[];
|
||||
extern files_struct Files[];
|
||||
extern int Client;
|
||||
extern int oplock_sock;
|
||||
@ -363,10 +362,9 @@ static int map_share_mode( uint32 desired_access, uint32 share_access, uint32 fi
|
||||
/****************************************************************************
|
||||
Reply to an NT create and X call on a pipe.
|
||||
****************************************************************************/
|
||||
|
||||
static int nt_open_pipe(char *fname, char *inbuf, char *outbuf, int *ppnum)
|
||||
static int nt_open_pipe(char *fname, connection_struct *conn,
|
||||
char *inbuf, char *outbuf, int *ppnum)
|
||||
{
|
||||
int cnum = SVAL(inbuf,smb_tid);
|
||||
int pnum = -1;
|
||||
uint16 vuid = SVAL(inbuf, smb_uid);
|
||||
int i;
|
||||
@ -386,7 +384,7 @@ static int nt_open_pipe(char *fname, char *inbuf, char *outbuf, int *ppnum)
|
||||
|
||||
DEBUG(3,("nt_open_pipe: Known pipe %s opening.\n", fname));
|
||||
|
||||
pnum = open_rpc_pipe_hnd(fname, cnum, vuid);
|
||||
pnum = open_rpc_pipe_hnd(fname, conn, vuid);
|
||||
if (pnum < 0)
|
||||
return(ERROR(ERRSRV,ERRnofids));
|
||||
|
||||
@ -397,280 +395,291 @@ static int nt_open_pipe(char *fname, char *inbuf, char *outbuf, int *ppnum)
|
||||
/****************************************************************************
|
||||
Reply to an NT create and X call.
|
||||
****************************************************************************/
|
||||
|
||||
int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
int reply_ntcreate_and_X(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize)
|
||||
{
|
||||
pstring fname;
|
||||
int cnum = SVAL(inbuf,smb_tid);
|
||||
int fnum = -1;
|
||||
uint32 flags = IVAL(inbuf,smb_ntcreate_Flags);
|
||||
uint32 desired_access = IVAL(inbuf,smb_ntcreate_DesiredAccess);
|
||||
uint32 file_attributes = IVAL(inbuf,smb_ntcreate_FileAttributes);
|
||||
uint32 share_access = IVAL(inbuf,smb_ntcreate_ShareAccess);
|
||||
uint32 create_disposition = IVAL(inbuf,smb_ntcreate_CreateDisposition);
|
||||
uint32 fname_len = MIN(((uint32)SVAL(inbuf,smb_ntcreate_NameLength)),
|
||||
((uint32)sizeof(fname)-1));
|
||||
int smb_ofun;
|
||||
int smb_open_mode;
|
||||
int smb_attr = (file_attributes & SAMBA_ATTRIBUTES_MASK);
|
||||
/* Breakout the oplock request bits so we can set the
|
||||
reply bits separately. */
|
||||
int oplock_request = 0;
|
||||
int unixmode;
|
||||
int fmode=0,mtime=0,rmode=0;
|
||||
off_t file_len = 0;
|
||||
struct stat sbuf;
|
||||
int smb_action = 0;
|
||||
BOOL bad_path = False;
|
||||
files_struct *fsp;
|
||||
char *p = NULL;
|
||||
|
||||
/*
|
||||
* We need to construct the open_and_X ofun value from the
|
||||
* NT values, as that's what our code is structured to accept.
|
||||
*/
|
||||
pstring fname;
|
||||
int fnum = -1;
|
||||
uint32 flags = IVAL(inbuf,smb_ntcreate_Flags);
|
||||
uint32 desired_access = IVAL(inbuf,smb_ntcreate_DesiredAccess);
|
||||
uint32 file_attributes = IVAL(inbuf,smb_ntcreate_FileAttributes);
|
||||
uint32 share_access = IVAL(inbuf,smb_ntcreate_ShareAccess);
|
||||
uint32 create_disposition = IVAL(inbuf,smb_ntcreate_CreateDisposition);
|
||||
uint32 fname_len = MIN(((uint32)SVAL(inbuf,smb_ntcreate_NameLength)),
|
||||
((uint32)sizeof(fname)-1));
|
||||
int smb_ofun;
|
||||
int smb_open_mode;
|
||||
int smb_attr = (file_attributes & SAMBA_ATTRIBUTES_MASK);
|
||||
/* Breakout the oplock request bits so we can set the
|
||||
reply bits separately. */
|
||||
int oplock_request = 0;
|
||||
int unixmode;
|
||||
int fmode=0,mtime=0,rmode=0;
|
||||
off_t file_len = 0;
|
||||
struct stat sbuf;
|
||||
int smb_action = 0;
|
||||
BOOL bad_path = False;
|
||||
files_struct *fsp=NULL;
|
||||
char *p = NULL;
|
||||
|
||||
if((smb_ofun = map_create_disposition( create_disposition )) == -1)
|
||||
return(ERROR(ERRDOS,ERRbadaccess));
|
||||
/*
|
||||
* We need to construct the open_and_X ofun value from the
|
||||
* NT values, as that's what our code is structured to accept.
|
||||
*/
|
||||
|
||||
if((smb_ofun = map_create_disposition( create_disposition )) == -1)
|
||||
return(ERROR(ERRDOS,ERRbadaccess));
|
||||
|
||||
/*
|
||||
* Now contruct the smb_open_mode value from the desired access
|
||||
* and the share access.
|
||||
*/
|
||||
/*
|
||||
* Now contruct the smb_open_mode value from the desired access
|
||||
* and the share access.
|
||||
*/
|
||||
|
||||
if((smb_open_mode = map_share_mode(desired_access,
|
||||
share_access,
|
||||
file_attributes)) == -1) {
|
||||
return(ERROR(ERRDOS,ERRbadaccess));
|
||||
}
|
||||
|
||||
if((smb_open_mode = map_share_mode( desired_access, share_access, file_attributes)) == -1)
|
||||
return(ERROR(ERRDOS,ERRbadaccess));
|
||||
/*
|
||||
* Get the file name.
|
||||
*/
|
||||
StrnCpy(fname,smb_buf(inbuf),fname_len);
|
||||
fname[fname_len] = '\0';
|
||||
|
||||
/* If it's an IPC, use the pipe handler. */
|
||||
if (IS_IPC(conn)) {
|
||||
int ret = nt_open_pipe(fname, conn, inbuf, outbuf, &fnum);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
smb_action = FILE_WAS_OPENED;
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Get the file name.
|
||||
*/
|
||||
StrnCpy(fname,smb_buf(inbuf),fname_len);
|
||||
fname[fname_len] = '\0';
|
||||
|
||||
/* If it's an IPC, use the pipe handler. */
|
||||
if (IS_IPC(cnum)) {
|
||||
int ret = nt_open_pipe(fname, inbuf, outbuf, &fnum);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
smb_action = FILE_WAS_OPENED;
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Ordinary file or directory.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Check if POSIX semantics are wanted.
|
||||
*/
|
||||
|
||||
set_posix_case_semantics(file_attributes);
|
||||
|
||||
unix_convert(fname,cnum,0,&bad_path);
|
||||
/*
|
||||
* Ordinary file or directory.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Check if POSIX semantics are wanted.
|
||||
*/
|
||||
|
||||
set_posix_case_semantics(file_attributes);
|
||||
|
||||
unix_convert(fname,conn,0,&bad_path);
|
||||
|
||||
fnum = find_free_file();
|
||||
if (fnum < 0) {
|
||||
restore_case_semantics(file_attributes);
|
||||
return(ERROR(ERRSRV,ERRnofids));
|
||||
}
|
||||
|
||||
fsp = &Files[fnum];
|
||||
|
||||
if (!check_name(fname,conn)) {
|
||||
if((errno == ENOENT) && bad_path) {
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRbadpath;
|
||||
}
|
||||
fsp->reserved = False;
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
unixmode = unix_mode(conn,smb_attr | aARCH);
|
||||
|
||||
fnum = find_free_file();
|
||||
if (fnum < 0) {
|
||||
restore_case_semantics(file_attributes);
|
||||
return(ERROR(ERRSRV,ERRnofids));
|
||||
}
|
||||
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
|
||||
oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
|
||||
|
||||
fsp = &Files[fnum];
|
||||
|
||||
if (!check_name(fname,cnum)) {
|
||||
if((errno == ENOENT) && bad_path) {
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRbadpath;
|
||||
}
|
||||
fsp->reserved = False;
|
||||
/*
|
||||
* If it's a request for a directory open, deal with it separately.
|
||||
*/
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
if(flags & OPEN_DIRECTORY) {
|
||||
oplock_request = 0;
|
||||
|
||||
open_directory(fnum, conn, fname, smb_ofun,
|
||||
unixmode, &smb_action);
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
unixmode = unix_mode(cnum,smb_attr | aARCH);
|
||||
|
||||
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
|
||||
oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
|
||||
if(!fsp->open) {
|
||||
fsp->reserved = False;
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Ordinary file case.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If it's a request for a directory open, deal with it separately.
|
||||
*/
|
||||
/* NB. We have a potential bug here. If we
|
||||
* cause an oplock break to ourselves, then we
|
||||
* could end up processing filename related
|
||||
* SMB requests whilst we await the oplock
|
||||
* break response. As we may have changed the
|
||||
* filename case semantics to be POSIX-like,
|
||||
* this could mean a filename request could
|
||||
* fail when it should succeed. This is a rare
|
||||
* condition, but eventually we must arrange
|
||||
* to restore the correct case semantics
|
||||
* before issuing an oplock break request to
|
||||
* our client. JRA. */
|
||||
|
||||
if(flags & OPEN_DIRECTORY) {
|
||||
oplock_request = 0;
|
||||
open_file_shared(fnum,conn,fname,smb_open_mode,
|
||||
smb_ofun,unixmode,
|
||||
oplock_request,&rmode,&smb_action);
|
||||
|
||||
open_directory(fnum, cnum, fname, smb_ofun, unixmode, &smb_action);
|
||||
if (!fsp->open) {
|
||||
/* We cheat here. The only case we
|
||||
* care about is a directory rename,
|
||||
* where the NT client will attempt to
|
||||
* open the source directory for
|
||||
* DELETE access. Note that when the
|
||||
* NT client does this it does *not*
|
||||
* set the directory bit in the *
|
||||
* request packet. This is translated
|
||||
* into a read/write open *
|
||||
* request. POSIX states that any open
|
||||
* for write request on a directory *
|
||||
* will generate an EISDIR error, so
|
||||
* we can catch this here and open * a
|
||||
* pseudo handle that is flagged as a
|
||||
* directory. JRA. */
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
if(!fsp->open) {
|
||||
fsp->reserved = False;
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Ordinary file case.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NB. We have a potential bug here. If we cause an oplock
|
||||
* break to ourselves, then we could end up processing filename
|
||||
* related SMB requests whilst we await the oplock break
|
||||
* response. As we may have changed the filename case
|
||||
* semantics to be POSIX-like, this could mean a filename
|
||||
* request could fail when it should succeed. This is a
|
||||
* rare condition, but eventually we must arrange to restore
|
||||
* the correct case semantics before issuing an oplock break
|
||||
* request to our client. JRA.
|
||||
*/
|
||||
|
||||
open_file_shared(fnum,cnum,fname,smb_open_mode,smb_ofun,unixmode,
|
||||
oplock_request,&rmode,&smb_action);
|
||||
|
||||
if (!fsp->open) {
|
||||
/*
|
||||
* We cheat here. The only case we care about is a directory
|
||||
* rename, where the NT client will attempt to open the source
|
||||
* directory for DELETE access. Note that when the NT client
|
||||
* does this it does *not* set the directory bit in the
|
||||
* request packet. This is translated into a read/write open
|
||||
* request. POSIX states that any open for write request on a directory
|
||||
* will generate an EISDIR error, so we can catch this here and open
|
||||
* a pseudo handle that is flagged as a directory. JRA.
|
||||
*/
|
||||
|
||||
if(errno == EISDIR) {
|
||||
oplock_request = 0;
|
||||
|
||||
open_directory(fnum, cnum, fname, smb_ofun, unixmode, &smb_action);
|
||||
|
||||
if(!fsp->open) {
|
||||
fsp->reserved = False;
|
||||
restore_case_semantics(file_attributes);
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
} else {
|
||||
if((errno == ENOENT) && bad_path) {
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRbadpath;
|
||||
}
|
||||
|
||||
fsp->reserved = False;
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fsp->is_directory) {
|
||||
if(sys_stat(fsp->name, &sbuf) != 0) {
|
||||
close_directory(fnum);
|
||||
restore_case_semantics(file_attributes);
|
||||
return(ERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
} else {
|
||||
if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
|
||||
close_file(fnum,False);
|
||||
restore_case_semantics(file_attributes);
|
||||
return(ERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
}
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
file_len = sbuf.st_size;
|
||||
fmode = dos_mode(cnum,fname,&sbuf);
|
||||
if(fmode == 0)
|
||||
fmode = FILE_ATTRIBUTE_NORMAL;
|
||||
mtime = sbuf.st_mtime;
|
||||
if (!fsp->is_directory && (fmode & aDIR)) {
|
||||
close_file(fnum,False);
|
||||
return(ERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
/*
|
||||
* If the caller set the extended oplock request bit
|
||||
* and we granted one (by whatever means) - set the
|
||||
* correct bit for extended oplock reply.
|
||||
*/
|
||||
|
||||
if (oplock_request && lp_fake_oplocks(SNUM(cnum)))
|
||||
smb_action |= EXTENDED_OPLOCK_GRANTED;
|
||||
|
||||
if(oplock_request && fsp->granted_oplock)
|
||||
smb_action |= EXTENDED_OPLOCK_GRANTED;
|
||||
}
|
||||
|
||||
set_message(outbuf,34,0,True);
|
||||
|
||||
p = outbuf + smb_vwv2;
|
||||
|
||||
/*
|
||||
* Currently as we don't support level II oplocks we just report
|
||||
* exclusive & batch here.
|
||||
*/
|
||||
|
||||
SCVAL(p,0, (smb_action & EXTENDED_OPLOCK_GRANTED ? 1 : 0));
|
||||
p++;
|
||||
SSVAL(p,0,fnum);
|
||||
p += 2;
|
||||
SIVAL(p,0,smb_action);
|
||||
p += 4;
|
||||
|
||||
if (IS_IPC(cnum)) {
|
||||
/*
|
||||
* Deal with pipe return.
|
||||
*/
|
||||
p += 32;
|
||||
SIVAL(p,0,FILE_ATTRIBUTE_NORMAL); /* File Attributes. */
|
||||
p += 20;
|
||||
/* File type. */
|
||||
SSVAL(p,0,FILE_TYPE_MESSAGE_MODE_PIPE);
|
||||
/* Device state. */
|
||||
SSVAL(p,2, 0x5FF); /* ? */
|
||||
} else {
|
||||
/*
|
||||
* Deal with file return.
|
||||
*/
|
||||
/* Create time. */
|
||||
put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_atime); /* access time */
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_mtime); /* write time */
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_mtime); /* change time */
|
||||
p += 8;
|
||||
SIVAL(p,0,fmode); /* File Attributes. */
|
||||
p += 12;
|
||||
if(errno == EISDIR) {
|
||||
oplock_request = 0;
|
||||
|
||||
open_directory(fnum, conn, fname, smb_ofun, unixmode, &smb_action);
|
||||
|
||||
if(!fsp->open) {
|
||||
fsp->reserved = False;
|
||||
restore_case_semantics(file_attributes);
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
} else {
|
||||
if((errno == ENOENT) && bad_path) {
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRbadpath;
|
||||
}
|
||||
|
||||
fsp->reserved = False;
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fsp->is_directory) {
|
||||
if(sys_stat(fsp->fsp_name, &sbuf) != 0) {
|
||||
close_directory(fnum);
|
||||
restore_case_semantics(file_attributes);
|
||||
return(ERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
} else {
|
||||
if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
|
||||
close_file(fnum,False);
|
||||
restore_case_semantics(file_attributes);
|
||||
return(ERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
}
|
||||
|
||||
restore_case_semantics(file_attributes);
|
||||
|
||||
file_len = sbuf.st_size;
|
||||
fmode = dos_mode(conn,fname,&sbuf);
|
||||
if(fmode == 0)
|
||||
fmode = FILE_ATTRIBUTE_NORMAL;
|
||||
mtime = sbuf.st_mtime;
|
||||
if (!fsp->is_directory && (fmode & aDIR)) {
|
||||
close_file(fnum,False);
|
||||
return(ERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
/*
|
||||
* If the caller set the extended oplock request bit
|
||||
* and we granted one (by whatever means) - set the
|
||||
* correct bit for extended oplock reply.
|
||||
*/
|
||||
|
||||
if (oplock_request && lp_fake_oplocks(SNUM(conn)))
|
||||
smb_action |= EXTENDED_OPLOCK_GRANTED;
|
||||
|
||||
if(oplock_request && fsp->granted_oplock)
|
||||
smb_action |= EXTENDED_OPLOCK_GRANTED;
|
||||
}
|
||||
|
||||
set_message(outbuf,34,0,True);
|
||||
|
||||
p = outbuf + smb_vwv2;
|
||||
|
||||
/*
|
||||
* Currently as we don't support level II oplocks we just report
|
||||
* exclusive & batch here.
|
||||
*/
|
||||
|
||||
SCVAL(p,0, (smb_action & EXTENDED_OPLOCK_GRANTED ? 1 : 0));
|
||||
p++;
|
||||
SSVAL(p,0,fnum);
|
||||
p += 2;
|
||||
SIVAL(p,0,smb_action);
|
||||
p += 4;
|
||||
|
||||
if (IS_IPC(conn)) {
|
||||
/*
|
||||
* Deal with pipe return.
|
||||
*/
|
||||
p += 32;
|
||||
SIVAL(p,0,FILE_ATTRIBUTE_NORMAL); /* File Attributes. */
|
||||
p += 20;
|
||||
/* File type. */
|
||||
SSVAL(p,0,FILE_TYPE_MESSAGE_MODE_PIPE);
|
||||
/* Device state. */
|
||||
SSVAL(p,2, 0x5FF); /* ? */
|
||||
} else {
|
||||
/*
|
||||
* Deal with file return.
|
||||
*/
|
||||
/* Create time. */
|
||||
put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_atime); /* access time */
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_mtime); /* write time */
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_mtime); /* change time */
|
||||
p += 8;
|
||||
SIVAL(p,0,fmode); /* File Attributes. */
|
||||
p += 12;
|
||||
#if OFF_T_IS_64_BITS
|
||||
SIVAL(p,0, file_len & 0xFFFFFFFF);
|
||||
SIVAL(p,4, file_len >> 32);
|
||||
SIVAL(p,0, file_len & 0xFFFFFFFF);
|
||||
SIVAL(p,4, file_len >> 32);
|
||||
#else /* OFF_T_IS_64_BITS */
|
||||
SIVAL(p,0,file_len);
|
||||
SIVAL(p,0,file_len);
|
||||
#endif /* OFF_T_IS_64_BITS */
|
||||
p += 12;
|
||||
SCVAL(p,0,fsp->is_directory ? 1 : 0);
|
||||
}
|
||||
p += 12;
|
||||
SCVAL(p,0,fsp->is_directory ? 1 : 0);
|
||||
}
|
||||
|
||||
chain_fnum = fnum;
|
||||
|
||||
chain_fnum = fnum;
|
||||
|
||||
DEBUG(5,("reply_ntcreate_and_X: open fnum = %d, name = %s\n",
|
||||
fnum, fsp?fsp->fsp_name:"NULL"));
|
||||
|
||||
DEBUG(5,("reply_ntcreate_and_X: open fnum = %d, name = %s\n",
|
||||
fnum, fsp->name ));
|
||||
|
||||
return chain_reply(inbuf,outbuf,length,bufsize);
|
||||
return chain_reply(inbuf,outbuf,length,bufsize);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to a NT_TRANSACT_CREATE call (needs to process SD's).
|
||||
****************************************************************************/
|
||||
|
||||
static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
int bufsize, int cnum,
|
||||
char **ppsetup, char **ppparams, char **ppdata)
|
||||
static int call_nt_transact_create(connection_struct *conn,
|
||||
char *inbuf, char *outbuf, int length,
|
||||
int bufsize,
|
||||
char **ppsetup, char **ppparams,
|
||||
char **ppdata)
|
||||
{
|
||||
pstring fname;
|
||||
int fnum = -1;
|
||||
@ -721,8 +730,8 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
fname[fname_len] = '\0';
|
||||
|
||||
/* If it's an IPC, use the pipe handler. */
|
||||
if (IS_IPC(cnum)) {
|
||||
int ret = nt_open_pipe(fname, inbuf, outbuf, &fnum);
|
||||
if (IS_IPC(conn)) {
|
||||
int ret = nt_open_pipe(fname, conn, inbuf, outbuf, &fnum);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
smb_action = FILE_WAS_OPENED;
|
||||
@ -733,7 +742,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
|
||||
set_posix_case_semantics(file_attributes);
|
||||
|
||||
unix_convert(fname,cnum,0,&bad_path);
|
||||
unix_convert(fname,conn,0,&bad_path);
|
||||
|
||||
fnum = find_free_file();
|
||||
if (fnum < 0) {
|
||||
@ -743,7 +752,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
|
||||
fsp = &Files[fnum];
|
||||
|
||||
if (!check_name(fname,cnum)) {
|
||||
if (!check_name(fname,conn)) {
|
||||
if((errno == ENOENT) && bad_path) {
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRbadpath;
|
||||
@ -755,7 +764,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||
}
|
||||
|
||||
unixmode = unix_mode(cnum,smb_attr | aARCH);
|
||||
unixmode = unix_mode(conn,smb_attr | aARCH);
|
||||
|
||||
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
|
||||
oplock_request |= (flags & REQUEST_BATCH_OPLOCK) ? BATCH_OPLOCK : 0;
|
||||
@ -774,7 +783,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
* CreateDirectory() call.
|
||||
*/
|
||||
|
||||
open_directory(fnum, cnum, fname, smb_ofun, unixmode, &smb_action);
|
||||
open_directory(fnum, conn, fname, smb_ofun, unixmode, &smb_action);
|
||||
|
||||
if(!fsp->open) {
|
||||
fsp->reserved = False;
|
||||
@ -786,7 +795,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
* Ordinary file case.
|
||||
*/
|
||||
|
||||
open_file_shared(fnum,cnum,fname,smb_open_mode,smb_ofun,unixmode,
|
||||
open_file_shared(fnum,conn,fname,smb_open_mode,smb_ofun,unixmode,
|
||||
oplock_request,&rmode,&smb_action);
|
||||
|
||||
if (!fsp->open) {
|
||||
@ -810,7 +819,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
}
|
||||
|
||||
file_len = sbuf.st_size;
|
||||
fmode = dos_mode(cnum,fname,&sbuf);
|
||||
fmode = dos_mode(conn,fname,&sbuf);
|
||||
if(fmode == 0)
|
||||
fmode = FILE_ATTRIBUTE_NORMAL;
|
||||
mtime = sbuf.st_mtime;
|
||||
@ -827,7 +836,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
* correct bit for extended oplock reply.
|
||||
*/
|
||||
|
||||
if (oplock_request && lp_fake_oplocks(SNUM(cnum)))
|
||||
if (oplock_request && lp_fake_oplocks(SNUM(conn)))
|
||||
smb_action |= EXTENDED_OPLOCK_GRANTED;
|
||||
|
||||
if(oplock_request && fsp->granted_oplock)
|
||||
@ -850,7 +859,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
SIVAL(p,0,smb_action);
|
||||
p += 8;
|
||||
|
||||
if (IS_IPC(cnum)) {
|
||||
if (IS_IPC(conn)) {
|
||||
/*
|
||||
* Deal with pipe return.
|
||||
*/
|
||||
@ -866,7 +875,7 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
* Deal with file return.
|
||||
*/
|
||||
/* Create time. */
|
||||
put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(cnum))));
|
||||
put_long_date(p,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
|
||||
p += 8;
|
||||
put_long_date(p,sbuf.st_atime); /* access time */
|
||||
p += 8;
|
||||
@ -893,39 +902,39 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
|
||||
/****************************************************************************
|
||||
Reply to a NT CANCEL request.
|
||||
****************************************************************************/
|
||||
|
||||
int reply_ntcancel(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
int reply_ntcancel(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize)
|
||||
{
|
||||
/*
|
||||
* Go through and cancel any pending change notifies.
|
||||
* TODO: When we add blocking locks we will add cancel
|
||||
* for them here too.
|
||||
*/
|
||||
/*
|
||||
* Go through and cancel any pending change notifies.
|
||||
* TODO: When we add blocking locks we will add cancel
|
||||
* for them here too.
|
||||
*/
|
||||
|
||||
int mid = SVAL(inbuf,smb_mid);
|
||||
remove_pending_change_notify_requests_by_mid(mid);
|
||||
|
||||
DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", mid));
|
||||
|
||||
int mid = SVAL(inbuf,smb_mid);
|
||||
remove_pending_change_notify_requests_by_mid(mid);
|
||||
|
||||
DEBUG(3,("reply_ntcancel: cancel called on mid = %d.\n", mid));
|
||||
|
||||
return(-1);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to an unsolicited SMBNTtranss - just ignore it!
|
||||
****************************************************************************/
|
||||
|
||||
int reply_nttranss(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
int reply_nttranss(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize)
|
||||
{
|
||||
DEBUG(4,("Ignoring nttranss of length %d\n",length));
|
||||
return(-1);
|
||||
DEBUG(4,("Ignoring nttranss of length %d\n",length));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to an NT transact rename command.
|
||||
****************************************************************************/
|
||||
|
||||
static int call_nt_transact_rename(char *inbuf, char *outbuf, int length,
|
||||
int bufsize, int cnum,
|
||||
static int call_nt_transact_rename(connection_struct *conn,
|
||||
char *inbuf, char *outbuf, int length,
|
||||
int bufsize,
|
||||
char **ppsetup, char **ppparams, char **ppdata)
|
||||
{
|
||||
char *params = *ppparams;
|
||||
@ -936,11 +945,11 @@ static int call_nt_transact_rename(char *inbuf, char *outbuf, int length,
|
||||
((uint32)sizeof(new_name)-1));
|
||||
int outsize = 0;
|
||||
|
||||
CHECK_FNUM(fnum, cnum);
|
||||
CHECK_FNUM(fnum, conn);
|
||||
StrnCpy(new_name,params+4,fname_len);
|
||||
new_name[fname_len] = '\0';
|
||||
|
||||
outsize = rename_internals(inbuf, outbuf, Files[fnum].name,
|
||||
outsize = rename_internals(conn, inbuf, outbuf, Files[fnum].fsp_name,
|
||||
new_name, replace_if_exists);
|
||||
if(outsize == 0) {
|
||||
/*
|
||||
@ -949,7 +958,7 @@ static int call_nt_transact_rename(char *inbuf, char *outbuf, int length,
|
||||
send_nt_replies(outbuf, bufsize, NULL, 0, NULL, 0);
|
||||
|
||||
DEBUG(3,("nt transact rename from = %s, to = %s succeeded.\n",
|
||||
Files[fnum].name, new_name));
|
||||
Files[fnum].fsp_name, new_name));
|
||||
|
||||
outsize = -1;
|
||||
}
|
||||
@ -967,7 +976,7 @@ static int call_nt_transact_rename(char *inbuf, char *outbuf, int length,
|
||||
typedef struct {
|
||||
ubi_slNode msg_next;
|
||||
int fnum;
|
||||
int cnum;
|
||||
connection_struct *conn;
|
||||
time_t next_check_time;
|
||||
time_t modify_time; /* Info from the directory we're monitoring. */
|
||||
time_t status_time; /* Info from the directory we're monitoring. */
|
||||
@ -1076,12 +1085,12 @@ void process_pending_change_notify_queue(time_t t)
|
||||
while((cnbp != NULL) && (cnbp->next_check_time <= t)) {
|
||||
struct stat st;
|
||||
int fnum = cnbp->fnum;
|
||||
int cnum = cnbp->cnum;
|
||||
connection_struct *conn = cnbp->conn;
|
||||
files_struct *fsp = &Files[fnum];
|
||||
uint16 vuid = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID :
|
||||
SVAL(cnbp->request_buf,smb_uid);
|
||||
|
||||
if(!become_user(&Connections[cnum],cnum,vuid)) {
|
||||
if(!become_user(conn,vuid)) {
|
||||
DEBUG(0,("process_pending_change_notify_queue: Unable to become user vuid=%d.\n",
|
||||
vuid ));
|
||||
/*
|
||||
@ -1093,9 +1102,8 @@ void process_pending_change_notify_queue(time_t t)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!become_service(cnum,True)) {
|
||||
DEBUG(0,("process_pending_change_notify_queue: Unable to become service cnum=%d. \
|
||||
Error was %s.\n", cnum, strerror(errno) ));
|
||||
if(!become_service(conn,True)) {
|
||||
DEBUG(0,("process_pending_change_notify_queue: Unable to become service Error was %s.\n", strerror(errno) ));
|
||||
/*
|
||||
* Remove the entry and return an error to the client.
|
||||
*/
|
||||
@ -1106,9 +1114,9 @@ Error was %s.\n", cnum, strerror(errno) ));
|
||||
continue;
|
||||
}
|
||||
|
||||
if(sys_stat(fsp->name, &st) < 0) {
|
||||
if(sys_stat(fsp->fsp_name, &st) < 0) {
|
||||
DEBUG(0,("process_pending_change_notify_queue: Unable to stat directory %s. \
|
||||
Error was %s.\n", fsp->name, strerror(errno) ));
|
||||
Error was %s.\n", fsp->fsp_name, strerror(errno) ));
|
||||
/*
|
||||
* Remove the entry and return an error to the client.
|
||||
*/
|
||||
@ -1125,7 +1133,7 @@ Error was %s.\n", fsp->name, strerror(errno) ));
|
||||
* Remove the entry and return a change notify to the client.
|
||||
*/
|
||||
DEBUG(5,("process_pending_change_notify_queue: directory fnum = %d, name = %s changed\n",
|
||||
fnum, fsp->name ));
|
||||
fnum, fsp->fsp_name ));
|
||||
change_notify_reply_packet(cnbp->request_buf,0,NT_STATUS_NOTIFY_ENUM_DIR);
|
||||
free((char *)ubi_slRemNext( &change_notify_queue, prev));
|
||||
cnbp = (change_notify_buf *)(prev ? ubi_slNext(prev) : ubi_slFirst(&change_notify_queue));
|
||||
@ -1147,10 +1155,11 @@ Error was %s.\n", fsp->name, strerror(errno) ));
|
||||
Reply to a notify change - queue the request and
|
||||
don't allow a directory to be opened.
|
||||
****************************************************************************/
|
||||
|
||||
static int call_nt_transact_notify_change(char *inbuf, char *outbuf, int length,
|
||||
int bufsize, int cnum,
|
||||
char **ppsetup, char **ppparams, char **ppdata)
|
||||
static int call_nt_transact_notify_change(connection_struct *conn,
|
||||
char *inbuf, char *outbuf, int length,
|
||||
int bufsize,
|
||||
char **ppsetup,
|
||||
char **ppparams, char **ppdata)
|
||||
{
|
||||
char *setup = *ppsetup;
|
||||
files_struct *fsp;
|
||||
@ -1167,7 +1176,7 @@ static int call_nt_transact_notify_change(char *inbuf, char *outbuf, int length,
|
||||
|
||||
fsp = &Files[fnum];
|
||||
|
||||
if((!fsp->open) || (!fsp->is_directory) || (cnum != fsp->cnum))
|
||||
if((!fsp->open) || (!fsp->is_directory) || (conn != fsp->conn))
|
||||
return(ERROR(ERRDOS,ERRbadfid));
|
||||
|
||||
/*
|
||||
@ -1187,16 +1196,16 @@ static int call_nt_transact_notify_change(char *inbuf, char *outbuf, int length,
|
||||
* Store the current timestamp on the directory we are monitoring.
|
||||
*/
|
||||
|
||||
if(sys_stat(fsp->name, &st) < 0) {
|
||||
if(sys_stat(fsp->fsp_name, &st) < 0) {
|
||||
DEBUG(0,("call_nt_transact_notify_change: Unable to stat fnum = %d, name = %s. \
|
||||
Error was %s\n", fnum, fsp->name, strerror(errno) ));
|
||||
Error was %s\n", fnum, fsp->fsp_name, strerror(errno) ));
|
||||
free((char *)cnbp);
|
||||
return(UNIXERROR(ERRDOS,ERRbadfid));
|
||||
}
|
||||
|
||||
memcpy(cnbp->request_buf, inbuf, smb_size);
|
||||
cnbp->fnum = fnum;
|
||||
cnbp->cnum = cnum;
|
||||
cnbp->conn = conn;
|
||||
cnbp->modify_time = st.st_mtime;
|
||||
cnbp->status_time = st.st_ctime;
|
||||
|
||||
@ -1211,7 +1220,7 @@ Error was %s\n", fnum, fsp->name, strerror(errno) ));
|
||||
ubi_slAddTail(&change_notify_queue, cnbp);
|
||||
|
||||
DEBUG(3,("call_nt_transact_notify_change: notify change called on directory \
|
||||
fid=%d, name = %s\n", fnum, fsp->name ));
|
||||
fid=%d, name = %s\n", fnum, fsp->fsp_name ));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -1220,9 +1229,10 @@ fid=%d, name = %s\n", fnum, fsp->name ));
|
||||
Reply to query a security descriptor - currently this is not implemented (it
|
||||
is planned to be though).
|
||||
****************************************************************************/
|
||||
|
||||
static int call_nt_transact_query_security_desc(char *inbuf, char *outbuf, int length,
|
||||
int bufsize, int cnum,
|
||||
static int call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
char *inbuf, char *outbuf,
|
||||
int length,
|
||||
int bufsize,
|
||||
char **ppsetup, char **ppparams, char **ppdata)
|
||||
{
|
||||
DEBUG(0,("call_nt_transact_query_security_desc: Currently not implemented.\n"));
|
||||
@ -1233,21 +1243,23 @@ static int call_nt_transact_query_security_desc(char *inbuf, char *outbuf, int l
|
||||
Reply to set a security descriptor - currently this is not implemented (it
|
||||
is planned to be though).
|
||||
****************************************************************************/
|
||||
|
||||
static int call_nt_transact_set_security_desc(char *inbuf, char *outbuf, int length,
|
||||
int bufsize, int cnum,
|
||||
char **ppsetup, char **ppparams, char **ppdata)
|
||||
static int call_nt_transact_set_security_desc(connection_struct *conn,
|
||||
char *inbuf, char *outbuf,
|
||||
int length,
|
||||
int bufsize,
|
||||
char **ppsetup,
|
||||
char **ppparams, char **ppdata)
|
||||
{
|
||||
DEBUG(0,("call_nt_transact_set_security_desc: Currently not implemented.\n"));
|
||||
return(ERROR(ERRSRV,ERRnosupport));
|
||||
DEBUG(0,("call_nt_transact_set_security_desc: Currently not implemented.\n"));
|
||||
return(ERROR(ERRSRV,ERRnosupport));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to IOCTL - not implemented - no plans.
|
||||
****************************************************************************/
|
||||
|
||||
static int call_nt_transact_ioctl(char *inbuf, char *outbuf, int length,
|
||||
int bufsize, int cnum,
|
||||
static int call_nt_transact_ioctl(connection_struct *conn,
|
||||
char *inbuf, char *outbuf, int length,
|
||||
int bufsize,
|
||||
char **ppsetup, char **ppparams, char **ppdata)
|
||||
{
|
||||
DEBUG(0,("call_nt_transact_ioctl: Currently not implemented.\n"));
|
||||
@ -1257,11 +1269,10 @@ static int call_nt_transact_ioctl(char *inbuf, char *outbuf, int length,
|
||||
/****************************************************************************
|
||||
Reply to a SMBNTtrans.
|
||||
****************************************************************************/
|
||||
|
||||
int reply_nttrans(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
int reply_nttrans(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize)
|
||||
{
|
||||
int outsize = 0;
|
||||
int cnum = SVAL(inbuf,smb_tid);
|
||||
#if 0 /* Not used. */
|
||||
uint16 max_setup_count = CVAL(inbuf, smb_nt_MaxSetupCount);
|
||||
uint32 max_parameter_count = IVAL(inbuf, smb_nt_MaxParameterCount);
|
||||
@ -1394,39 +1405,45 @@ due to being in oplock break state.\n" ));
|
||||
/* Now we must call the relevant NT_TRANS function */
|
||||
switch(function_code) {
|
||||
case NT_TRANSACT_CREATE:
|
||||
outsize = call_nt_transact_create(inbuf, outbuf, length, bufsize, cnum,
|
||||
outsize = call_nt_transact_create(conn, inbuf, outbuf, length, bufsize,
|
||||
&setup, ¶ms, &data);
|
||||
break;
|
||||
case NT_TRANSACT_IOCTL:
|
||||
outsize = call_nt_transact_ioctl(inbuf, outbuf, length, bufsize, cnum,
|
||||
outsize = call_nt_transact_ioctl(conn,
|
||||
inbuf, outbuf, length, bufsize,
|
||||
&setup, ¶ms, &data);
|
||||
break;
|
||||
case NT_TRANSACT_SET_SECURITY_DESC:
|
||||
outsize = call_nt_transact_set_security_desc(inbuf, outbuf, length, bufsize, cnum,
|
||||
outsize = call_nt_transact_set_security_desc(conn, inbuf, outbuf,
|
||||
length, bufsize,
|
||||
&setup, ¶ms, &data);
|
||||
break;
|
||||
case NT_TRANSACT_NOTIFY_CHANGE:
|
||||
outsize = call_nt_transact_notify_change(inbuf, outbuf, length, bufsize, cnum,
|
||||
outsize = call_nt_transact_notify_change(conn, inbuf, outbuf,
|
||||
length, bufsize,
|
||||
&setup, ¶ms, &data);
|
||||
break;
|
||||
case NT_TRANSACT_RENAME:
|
||||
outsize = call_nt_transact_rename(inbuf, outbuf, length, bufsize, cnum,
|
||||
outsize = call_nt_transact_rename(conn, inbuf, outbuf, length,
|
||||
bufsize,
|
||||
&setup, ¶ms, &data);
|
||||
break;
|
||||
|
||||
case NT_TRANSACT_QUERY_SECURITY_DESC:
|
||||
outsize = call_nt_transact_query_security_desc(inbuf, outbuf, length, bufsize, cnum,
|
||||
outsize = call_nt_transact_query_security_desc(conn, inbuf, outbuf,
|
||||
length, bufsize,
|
||||
&setup, ¶ms, &data);
|
||||
break;
|
||||
default:
|
||||
/* Error in request */
|
||||
DEBUG(0,("reply_nttrans: Unknown request %d in nttrans call\n", function_code));
|
||||
if(setup)
|
||||
free(setup);
|
||||
if(params)
|
||||
free(params);
|
||||
if(data)
|
||||
free(data);
|
||||
return (ERROR(ERRSRV,ERRerror));
|
||||
default:
|
||||
/* Error in request */
|
||||
DEBUG(0,("reply_nttrans: Unknown request %d in nttrans call\n", function_code));
|
||||
if(setup)
|
||||
free(setup);
|
||||
if(params)
|
||||
free(params);
|
||||
if(data)
|
||||
free(data);
|
||||
return (ERROR(ERRSRV,ERRerror));
|
||||
}
|
||||
|
||||
/* As we do not know how many data packets will need to be
|
||||
|
@ -58,10 +58,10 @@ extern struct pipe_id_info pipe_names[];
|
||||
This code is basically stolen from reply_open_and_X with some
|
||||
wrinkles to handle pipes.
|
||||
****************************************************************************/
|
||||
int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
int reply_open_pipe_and_X(connection_struct *conn,
|
||||
char *inbuf,char *outbuf,int length,int bufsize)
|
||||
{
|
||||
pstring fname;
|
||||
uint16 cnum = SVAL(inbuf, smb_tid);
|
||||
uint16 vuid = SVAL(inbuf, smb_uid);
|
||||
int pnum = -1;
|
||||
int smb_ofun = SVAL(inbuf,smb_vwv8);
|
||||
@ -95,7 +95,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
DEBUG(3,("Known pipe %s opening.\n",fname));
|
||||
smb_ofun |= 0x10; /* Add Create it not exists flag */
|
||||
|
||||
pnum = open_rpc_pipe_hnd(fname, cnum, vuid);
|
||||
pnum = open_rpc_pipe_hnd(fname, conn, vuid);
|
||||
if (pnum < 0) return(ERROR(ERRSRV,ERRnofids));
|
||||
|
||||
/* Prepare the reply */
|
||||
@ -134,13 +134,10 @@ int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
uint32 smb_offs = IVAL(inbuf,smb_vwv3);
|
||||
int smb_maxcnt = SVAL(inbuf,smb_vwv5);
|
||||
int smb_mincnt = SVAL(inbuf,smb_vwv6);
|
||||
int cnum;
|
||||
int nread = -1;
|
||||
char *data;
|
||||
BOOL ok = False;
|
||||
|
||||
cnum = SVAL(inbuf,smb_tid);
|
||||
|
||||
/*
|
||||
CHECK_FNUM(fnum,cnum);
|
||||
CHECK_READ(fnum);
|
||||
@ -161,8 +158,8 @@ int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
|
||||
SSVAL(smb_buf(outbuf),-2,nread);
|
||||
|
||||
DEBUG( 3, ( "readX pnum=%04x cnum=%d min=%d max=%d nread=%d\n",
|
||||
pnum, cnum, smb_mincnt, smb_maxcnt, nread ) );
|
||||
DEBUG(3,("readX pnum=%04x min=%d max=%d nread=%d\n",
|
||||
pnum, smb_mincnt, smb_maxcnt, nread));
|
||||
|
||||
set_chain_pnum(pnum);
|
||||
|
||||
@ -171,15 +168,14 @@ int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
|
||||
/****************************************************************************
|
||||
reply to a close
|
||||
****************************************************************************/
|
||||
int reply_pipe_close(char *inbuf,char *outbuf)
|
||||
int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf)
|
||||
{
|
||||
int pnum = get_rpc_pipe_num(inbuf,smb_vwv0);
|
||||
int cnum = SVAL(inbuf,smb_tid);
|
||||
int outsize = set_message(outbuf,0,0,True);
|
||||
|
||||
DEBUG(5,("reply_pipe_close: pnum:%x cnum:%x\n", pnum, cnum));
|
||||
DEBUG(5,("reply_pipe_close: pnum:%x\n", pnum));
|
||||
|
||||
if (!close_rpc_pipe_hnd(pnum, cnum)) return(ERROR(ERRDOS,ERRbadfid));
|
||||
if (!close_rpc_pipe_hnd(pnum, conn)) return(ERROR(ERRDOS,ERRbadfid));
|
||||
|
||||
return(outsize);
|
||||
}
|
||||
|
1755
source3/smbd/reply.c
1755
source3/smbd/reply.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,7 @@ static int initial_uid;
|
||||
static int initial_gid;
|
||||
|
||||
/* what user is current? */
|
||||
struct current_user current_user;
|
||||
extern struct current_user current_user;
|
||||
|
||||
pstring OriginalDir;
|
||||
|
||||
@ -51,7 +51,7 @@ void init_uid(void)
|
||||
initial_uid = geteuid();
|
||||
initial_gid = getegid();
|
||||
|
||||
current_user.cnum = -1;
|
||||
current_user.conn = NULL;
|
||||
current_user.vuid = UID_FIELD_INVALID;
|
||||
|
||||
ChDir(OriginalDir);
|
||||
@ -180,7 +180,7 @@ BOOL become_guest(void)
|
||||
DEBUG(1,("Failed to become guest. Invalid guest account?\n"));
|
||||
}
|
||||
|
||||
current_user.cnum = -2;
|
||||
current_user.conn = NULL;
|
||||
current_user.vuid = UID_FIELD_INVALID;
|
||||
|
||||
return(ret);
|
||||
@ -210,90 +210,89 @@ static BOOL check_user_ok(connection_struct *conn, user_struct *vuser,int snum)
|
||||
/****************************************************************************
|
||||
become the user of a connection number
|
||||
****************************************************************************/
|
||||
BOOL become_user(connection_struct *conn, int cnum, uint16 vuid)
|
||||
BOOL become_user(connection_struct *conn, uint16 vuid)
|
||||
{
|
||||
user_struct *vuser = get_valid_user_struct(vuid);
|
||||
int snum,gid;
|
||||
int uid;
|
||||
user_struct *vuser = get_valid_user_struct(vuid);
|
||||
int snum,gid;
|
||||
int uid;
|
||||
|
||||
/*
|
||||
* We need a separate check in security=share mode due to vuid
|
||||
* always being UID_FIELD_INVALID. If we don't do this then
|
||||
* in share mode security we are *always* changing uid's between
|
||||
* SMB's - this hurts performance - Badly.
|
||||
*/
|
||||
/*
|
||||
* We need a separate check in security=share mode due to vuid
|
||||
* always being UID_FIELD_INVALID. If we don't do this then
|
||||
* in share mode security we are *always* changing uid's between
|
||||
* SMB's - this hurts performance - Badly.
|
||||
*/
|
||||
|
||||
if((lp_security() == SEC_SHARE) && (current_user.cnum == cnum) &&
|
||||
(current_user.uid == conn->uid)) {
|
||||
DEBUG(4,("Skipping become_user - already user\n"));
|
||||
return(True);
|
||||
} else if ((current_user.cnum == cnum) && (vuser != 0) && (current_user.vuid == vuid) &&
|
||||
(current_user.uid == vuser->uid)) {
|
||||
DEBUG(4,("Skipping become_user - already user\n"));
|
||||
return(True);
|
||||
}
|
||||
if((lp_security() == SEC_SHARE) && (current_user.conn == conn) &&
|
||||
(current_user.uid == conn->uid)) {
|
||||
DEBUG(4,("Skipping become_user - already user\n"));
|
||||
return(True);
|
||||
} else if ((current_user.conn == conn) &&
|
||||
(vuser != 0) && (current_user.vuid == vuid) &&
|
||||
(current_user.uid == vuser->uid)) {
|
||||
DEBUG(4,("Skipping become_user - already user\n"));
|
||||
return(True);
|
||||
}
|
||||
|
||||
unbecome_user();
|
||||
unbecome_user();
|
||||
|
||||
if (!(VALID_CNUM(cnum) && conn->open)) {
|
||||
DEBUG(2,("Connection %d not open\n",cnum));
|
||||
return(False);
|
||||
}
|
||||
if (!(conn && conn->open)) {
|
||||
DEBUG(2,("Connection not open\n"));
|
||||
return(False);
|
||||
}
|
||||
|
||||
snum = conn->service;
|
||||
snum = SNUM(conn);
|
||||
|
||||
if((vuser != NULL) && !check_user_ok(conn, vuser, snum))
|
||||
return False;
|
||||
if((vuser != NULL) && !check_user_ok(conn, vuser, snum))
|
||||
return False;
|
||||
|
||||
if (conn->force_user ||
|
||||
lp_security() == SEC_SHARE ||
|
||||
!(vuser) || (vuser->guest)
|
||||
)
|
||||
{
|
||||
uid = conn->uid;
|
||||
gid = conn->gid;
|
||||
current_user.groups = conn->groups;
|
||||
current_user.ngroups = conn->ngroups;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vuser) {
|
||||
DEBUG(2,("Invalid vuid used %d\n",vuid));
|
||||
return(False);
|
||||
}
|
||||
uid = vuser->uid;
|
||||
if(!*lp_force_group(snum))
|
||||
gid = vuser->gid;
|
||||
else
|
||||
gid = conn->gid;
|
||||
current_user.ngroups = vuser->n_groups;
|
||||
current_user.groups = vuser->groups;
|
||||
}
|
||||
|
||||
if (initial_uid == 0)
|
||||
{
|
||||
if (!become_gid(gid)) return(False);
|
||||
if (conn->force_user ||
|
||||
lp_security() == SEC_SHARE ||
|
||||
!(vuser) || (vuser->guest)) {
|
||||
uid = conn->uid;
|
||||
gid = conn->gid;
|
||||
current_user.groups = conn->groups;
|
||||
current_user.ngroups = conn->ngroups;
|
||||
} else {
|
||||
if (!vuser) {
|
||||
DEBUG(2,("Invalid vuid used %d\n",vuid));
|
||||
return(False);
|
||||
}
|
||||
uid = vuser->uid;
|
||||
if(!*lp_force_group(snum)) {
|
||||
gid = vuser->gid;
|
||||
} else {
|
||||
gid = conn->gid;
|
||||
}
|
||||
current_user.ngroups = vuser->n_groups;
|
||||
current_user.groups = vuser->groups;
|
||||
}
|
||||
|
||||
if (initial_uid == 0) {
|
||||
if (!become_gid(gid)) return(False);
|
||||
|
||||
#ifdef HAVE_SETGROUPS
|
||||
if (!(VALID_CNUM(cnum) && conn->ipc)) {
|
||||
/* groups stuff added by ih/wreu */
|
||||
if (current_user.ngroups > 0)
|
||||
if (setgroups(current_user.ngroups,current_user.groups)<0)
|
||||
DEBUG(0,("setgroups call failed!\n"));
|
||||
}
|
||||
if (!(conn && conn->ipc)) {
|
||||
/* groups stuff added by ih/wreu */
|
||||
if (current_user.ngroups > 0)
|
||||
if (setgroups(current_user.ngroups,
|
||||
current_user.groups)<0) {
|
||||
DEBUG(0,("setgroups call failed!\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!conn->admin_user && !become_uid(uid))
|
||||
return(False);
|
||||
}
|
||||
if (!conn->admin_user && !become_uid(uid))
|
||||
return(False);
|
||||
}
|
||||
|
||||
current_user.conn = conn;
|
||||
current_user.vuid = vuid;
|
||||
|
||||
current_user.cnum = cnum;
|
||||
current_user.vuid = vuid;
|
||||
|
||||
DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
|
||||
getuid(),geteuid(),getgid(),getegid()));
|
||||
DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
|
||||
getuid(),geteuid(),getgid(),getegid()));
|
||||
|
||||
return(True);
|
||||
return(True);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -301,7 +300,7 @@ BOOL become_user(connection_struct *conn, int cnum, uint16 vuid)
|
||||
****************************************************************************/
|
||||
BOOL unbecome_user(void )
|
||||
{
|
||||
if (current_user.cnum == -1)
|
||||
if (!current_user.conn)
|
||||
return(False);
|
||||
|
||||
ChDir(OriginalDir);
|
||||
@ -343,158 +342,12 @@ BOOL unbecome_user(void )
|
||||
DEBUG(5,("unbecome_user now uid=(%d,%d) gid=(%d,%d)\n",
|
||||
getuid(),geteuid(),getgid(),getegid()));
|
||||
|
||||
current_user.cnum = -1;
|
||||
current_user.conn = NULL;
|
||||
current_user.vuid = UID_FIELD_INVALID;
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
This is a utility function of smbrun(). It must be called only from
|
||||
the child as it may leave the caller in a privilaged state.
|
||||
****************************************************************************/
|
||||
static BOOL setup_stdout_file(char *outfile,BOOL shared)
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
mode_t mode = S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH;
|
||||
int flags = O_RDWR|O_CREAT|O_TRUNC|O_EXCL;
|
||||
|
||||
close(1);
|
||||
|
||||
if (shared) {
|
||||
/* become root - unprivilaged users can't delete these files */
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresgid(0,0,0);
|
||||
setresuid(0,0,0);
|
||||
#else
|
||||
setuid(0);
|
||||
seteuid(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
if(stat(outfile, &st) == 0) {
|
||||
/* Check we're not deleting a device file. */
|
||||
if(st.st_mode & S_IFREG)
|
||||
unlink(outfile);
|
||||
else
|
||||
flags = O_RDWR;
|
||||
}
|
||||
/* now create the file */
|
||||
fd = open(outfile,flags,mode);
|
||||
|
||||
if (fd == -1) return False;
|
||||
|
||||
if (fd != 1) {
|
||||
if (dup2(fd,1) != 0) {
|
||||
DEBUG(2,("Failed to create stdout file descriptor\n"));
|
||||
close(fd);
|
||||
return False;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
run a command being careful about uid/gid handling and putting the output in
|
||||
outfile (or discard it if outfile is NULL).
|
||||
|
||||
if shared is True then ensure the file will be writeable by all users
|
||||
but created such that its owned by root. This overcomes a security hole.
|
||||
|
||||
if shared is not set then open the file with O_EXCL set
|
||||
****************************************************************************/
|
||||
int smbrun(char *cmd,char *outfile,BOOL shared)
|
||||
{
|
||||
int fd,pid;
|
||||
int uid = current_user.uid;
|
||||
int gid = current_user.gid;
|
||||
|
||||
#ifndef HAVE_EXECL
|
||||
int ret;
|
||||
pstring syscmd;
|
||||
char *path = lp_smbrun();
|
||||
|
||||
/* in the old method we use system() to execute smbrun which then
|
||||
executes the command (using system() again!). This involves lots
|
||||
of shell launches and is very slow. It also suffers from a
|
||||
potential security hole */
|
||||
if (!file_exist(path,NULL))
|
||||
{
|
||||
DEBUG(0,("SMBRUN ERROR: Can't find %s. Installation problem?\n",path));
|
||||
return(1);
|
||||
}
|
||||
|
||||
slprintf(syscmd,sizeof(syscmd)-1,"%s %d %d \"(%s 2>&1) > %s\"",
|
||||
path,uid,gid,cmd,
|
||||
outfile?outfile:"/dev/null");
|
||||
|
||||
DEBUG(5,("smbrun - running %s ",syscmd));
|
||||
ret = system(syscmd);
|
||||
DEBUG(5,("gave %d\n",ret));
|
||||
return(ret);
|
||||
#else
|
||||
/* in this newer method we will exec /bin/sh with the correct
|
||||
arguments, after first setting stdout to point at the file */
|
||||
|
||||
if ((pid=fork())) {
|
||||
int status=0;
|
||||
/* the parent just waits for the child to exit */
|
||||
if (sys_waitpid(pid,&status,0) != pid) {
|
||||
DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
|
||||
return -1;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* we are in the child. we exec /bin/sh to do the work for us. we
|
||||
don't directly exec the command we want because it may be a
|
||||
pipeline or anything else the config file specifies */
|
||||
|
||||
/* point our stdout at the file we want output to go into */
|
||||
if (outfile && !setup_stdout_file(outfile,shared)) {
|
||||
exit(80);
|
||||
}
|
||||
|
||||
/* now completely lose our privilages. This is a fairly paranoid
|
||||
way of doing it, but it does work on all systems that I know of */
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresgid(0,0,0);
|
||||
setresuid(0,0,0);
|
||||
setresgid(gid,gid,gid);
|
||||
setresuid(uid,uid,uid);
|
||||
#else
|
||||
setuid(0);
|
||||
seteuid(0);
|
||||
setgid(gid);
|
||||
setegid(gid);
|
||||
setuid(uid);
|
||||
seteuid(uid);
|
||||
#endif
|
||||
|
||||
if (getuid() != uid || geteuid() != uid ||
|
||||
getgid() != gid || getegid() != gid) {
|
||||
/* we failed to lose our privilages - do not execute the command */
|
||||
exit(81); /* we can't print stuff at this stage, instead use exit codes
|
||||
for debugging */
|
||||
}
|
||||
|
||||
/* close all other file descriptors, leaving only 0, 1 and 2. 0 and
|
||||
2 point to /dev/null from the startup code */
|
||||
for (fd=3;fd<256;fd++) close(fd);
|
||||
|
||||
execl("/bin/sh","sh","-c",cmd,NULL);
|
||||
|
||||
/* not reached */
|
||||
exit(82);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct current_user current_user_saved;
|
||||
static int become_root_depth;
|
||||
static pstring become_root_dir;
|
||||
|
@ -61,9 +61,7 @@ int locks_only = 0; /* Added by RJS */
|
||||
/* we need these because we link to locking*.o */
|
||||
void become_root(BOOL save_dir) {}
|
||||
void unbecome_root(BOOL restore_dir) {}
|
||||
connection_struct Connections[MAX_CONNECTIONS];
|
||||
files_struct Files[MAX_OPEN_FILES];
|
||||
struct current_user current_user;
|
||||
|
||||
|
||||
/* added by OH */
|
||||
|
@ -36,9 +36,7 @@ static pstring servicesf = CONFIGFILE;
|
||||
void unbecome_root(BOOL restore_dir) {}
|
||||
/* We need this because we link to password.o */
|
||||
BOOL change_oem_password(struct smb_passwd *smbpw, char *new_passwd, BOOL override) {return False;}
|
||||
connection_struct Connections[MAX_CONNECTIONS];
|
||||
files_struct Files[MAX_OPEN_FILES];
|
||||
struct current_user current_user;
|
||||
|
||||
static int enum_index(int value, struct enum_list *enumlist)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user