From 1441e0f3f78abb2c7a7f51307cdd33221e65075b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 31 May 2005 14:02:41 +0000 Subject: [PATCH] r7141: more sync ups with 3.0; remove printerdb header; remove old tdbsam2 header --- source/Makefile.in | 7 +- source/auth/auth_compat.c | 5 +- source/auth/auth_sam.c | 3 +- source/auth/auth_util.c | 21 +----- source/client/mount.cifs.c | 42 ++++++++++-- source/client/umount.cifs.c | 131 +++++++++++++++++++++++------------- source/include/includes.h | 2 - source/include/printerdb.h | 81 ---------------------- source/include/smb_macros.h | 6 ++ source/include/tdbsam2_parse_info.h | 2 - source/lib/dummyroot.c | 3 +- source/lib/dummysmbd.c | 2 +- source/libsmb/clifile.c | 4 +- source/libsmb/clikrb5.c | 4 +- source/libsmb/trustdom_cache.c | 2 +- source/modules/vfs_fake_perms.c | 6 +- source/nmbd/nmbd.c | 4 +- source/nsswitch/wb_client.c | 76 --------------------- source/pam_smbpass/pam_smb_auth.c | 2 +- source/pam_smbpass/pam_smb_passwd.c | 2 +- source/pam_smbpass/support.c | 7 +- source/smbd/dir.c | 1 - source/smbd/fake_file.c | 3 +- source/smbd/oplock.c | 8 +-- source/smbd/oplock_linux.c | 3 +- source/smbd/quotas.c | 28 ++++---- source/smbd/trans2.c | 2 +- source/tdb/tdbbackup.c | 5 +- source/tdb/tdbutil.c | 4 +- source/utils/net_lookup.c | 4 +- source/utils/ntlm_auth.c | 4 +- 31 files changed, 183 insertions(+), 291 deletions(-) delete mode 100644 source/include/printerdb.h delete mode 100644 source/include/tdbsam2_parse_info.h diff --git a/source/Makefile.in b/source/Makefile.in index 52ae258e09e..9fb070398c7 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -131,10 +131,6 @@ BIN_PROGS3 = bin/smbpasswd@EXEEXT@ bin/rpcclient@EXEEXT@ bin/smbcacls@EXEEXT@ \ bin/profiles@EXEEXT@ bin/ntlm_auth@EXEEXT@ \ bin/smbcquotas@EXEEXT@ -# editreg removed from standard build until it is portable. It needs a major rewrite to -# achieve this (tridge) -# bin/editreg@EXEEXT@ - TORTURE_PROGS = bin/smbtorture@EXEEXT@ bin/msgtest@EXEEXT@ \ bin/masktest@EXEEXT@ bin/locktest@EXEEXT@ \ bin/locktest2@EXEEXT@ bin/nsstest@EXEEXT@ bin/vfstest@EXEEXT@ @@ -274,6 +270,7 @@ RPC_SAMR_OBJ = rpc_server/srv_samr.o rpc_server/srv_samr_nt.o \ rpc_server/srv_samr_util.o RPC_UNIXINFO_OBJ = rpc_server/srv_unixinfo.o rpc_server/srv_unixinfo_nt.o +REGFIO_OBJ = registry/regfio.o RPC_REG_OBJ = rpc_server/srv_reg.o rpc_server/srv_reg_nt.o $(REGFIO_OBJ) @@ -377,8 +374,6 @@ MANGLE_OBJ = smbd/mangle.o smbd/mangle_hash.o smbd/mangle_map.o smbd/mangle_hash CONFIG_LDAP_OBJ = param/config_ldap.o -REGFIO_OBJ = registry/regfio.o - SMBD_OBJ_MAIN = smbd/server.o BUILDOPT_OBJ = smbd/build_options.o diff --git a/source/auth/auth_compat.c b/source/auth/auth_compat.c index a70f1e98b72..2ac70d73546 100644 --- a/source/auth/auth_compat.c +++ b/source/auth/auth_compat.c @@ -20,6 +20,9 @@ #include "includes.h" +extern struct auth_context *negprot_global_auth_context; +extern BOOL global_encrypted_passwords_negotiated; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH @@ -68,7 +71,6 @@ static NTSTATUS pass_check_smb(const char *smb_name, { NTSTATUS nt_status; - extern struct auth_context *negprot_global_auth_context; auth_serversupplied_info *server_info = NULL; if (encrypted) { auth_usersupplied_info *user_info = NULL; @@ -94,7 +96,6 @@ BOOL password_ok(char *smb_name, DATA_BLOB password_blob) { DATA_BLOB null_password = data_blob(NULL, 0); - extern BOOL global_encrypted_passwords_negotiated; BOOL encrypted = (global_encrypted_passwords_negotiated && password_blob.length == 24); if (encrypted) { diff --git a/source/auth/auth_sam.c b/source/auth/auth_sam.c index 9da59f220aa..023e441e241 100644 --- a/source/auth/auth_sam.c +++ b/source/auth/auth_sam.c @@ -23,6 +23,8 @@ #include "includes.h" +extern struct timeval smb_last_time; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH @@ -74,7 +76,6 @@ static NTSTATUS sam_password_ok(const struct auth_context *auth_context, static BOOL logon_hours_ok(SAM_ACCOUNT *sampass) { /* In logon hours first bit is Sunday from 12AM to 1AM */ - extern struct timeval smb_last_time; const uint8 *hours; struct tm *utctime; uint8 bitmask, bitpos; diff --git a/source/auth/auth_util.c b/source/auth/auth_util.c index d3a057fb10a..79205f1206d 100644 --- a/source/auth/auth_util.c +++ b/source/auth/auth_util.c @@ -51,23 +51,6 @@ static int smb_create_user(const char *domain, const char *unix_username, const } /**************************************************************************** - Add and Delete UNIX users on demand, based on NTSTATUS codes. - We don't care about RID's here so ignore. -****************************************************************************/ - -void auth_add_user_script(const char *domain, const char *username) -{ - /* - * User validated ok against Domain controller. - * If the admin wants us to try and create a UNIX - * user on the fly, do so. - */ - - if ( *lp_adduser_script() ) - smb_create_user(domain, username, NULL); -} - -/**************************************************************************** Create a SAM_ACCOUNT - either by looking in the pdb, or by faking it up from unix info. ****************************************************************************/ @@ -1081,7 +1064,7 @@ struct passwd *smb_getpwnam( char *domuser, fstring save_username, BOOL create ) if (username[strlen(username)-1] == '$') return NULL; - auth_add_user_script(NULL, username); + smb_create_user(NULL, username, NULL); pw = Get_Pwnam(username); } @@ -1170,7 +1153,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER)) { DEBUG(3,("User %s does not exist, trying to add it\n", internal_username)); - auth_add_user_script( nt_domain, sent_nt_username ); + smb_create_user( nt_domain, sent_nt_username, NULL); nt_status = fill_sam_account( mem_ctx, nt_domain, sent_nt_username, &found_username, &uid, &gid, &sam_account ); } diff --git a/source/client/mount.cifs.c b/source/client/mount.cifs.c index 3145447cc4e..9c0f582d85f 100755 --- a/source/client/mount.cifs.c +++ b/source/client/mount.cifs.c @@ -39,7 +39,7 @@ #include #define MOUNT_CIFS_VERSION_MAJOR "1" -#define MOUNT_CIFS_VERSION_MINOR "7" +#define MOUNT_CIFS_VERSION_MINOR "8" #ifndef MOUNT_CIFS_VENDOR_SUFFIX #define MOUNT_CIFS_VENDOR_SUFFIX "" @@ -83,7 +83,7 @@ static void mount_cifs_usage(void) printf(" to a local directory.\n\nOptions:\n"); printf("\tuser=\n\tpass=\n\tdom=\n"); printf("\nLess commonly used options:"); - printf("\n\tcredentials=,guest,perm,noperm,setuids,nosetuids,rw,ro,\n\tsep=,iocharset=,suid,nosuid,exec,noexec,serverino,\n\tdirectio"); + printf("\n\tcredentials=,guest,perm,noperm,setuids,nosetuids,rw,ro,\n\tsep=,iocharset=,suid,nosuid,exec,noexec,serverino,\n\tdirectio,mapchars,nomapchars"); printf("\n\nOptions not needed for servers supporting CIFS Unix extensions\n\t(e.g. most Samba versions):"); printf("\n\tuid=,gid=,dir_mode=,file_mode="); printf("\n\nRarely used options:"); @@ -185,13 +185,41 @@ static int open_cred_file(char * file_name) } else memset(mountpassword,0,64); if(mountpassword) { - /* BB add handling for commas in password here */ strncpy(mountpassword,temp_val,length); got_password = 1; } } } - } + } else if (strncasecmp("domain",line_buf+i,6) == 0) { + temp_val = strchr(line_buf+i,'='); + if(temp_val) { + /* go past equals sign */ + temp_val++; + if(verboseflag) + printf("\nDomain %s\n",temp_val); + for(length = 0;length<65;length++) { + if(temp_val[length] == '\n') + break; + } + if(length > 64) { + printf("mount.cifs failed: domain in credentials file too long\n"); + if(mountpassword) { + memset(mountpassword,0,64); + } + exit(1); + } else { + if(domain_name == NULL) { + domain_name = calloc(65,1); + } else + memset(domain_name,0,64); + if(domain_name) { + strncpy(domain_name,temp_val,length); + got_domain = 1; + } + } + } + } + } fclose(fs); if(line_buf) { @@ -494,6 +522,8 @@ static int parse_options(char * options, int * filesys_flags) *filesys_flags |= MS_RDONLY; } else if (strncmp(data, "rw", 2) == 0) { *filesys_flags &= ~MS_RDONLY; + } else if (strncmp(data, "remount", 7) == 0) { + *filesys_flags |= MS_REMOUNT; } /* else if (strnicmp(data, "port", 4) == 0) { if (value && *value) { vol->port = @@ -886,6 +916,7 @@ int main(int argc, char ** argv) break; case 'd': domain_name = optarg; /* BB fix this - currently ignored */ + got_domain = 1; break; case 'p': if(mountpassword == NULL) @@ -1015,7 +1046,8 @@ mount_retry: if(user_name) { /* check for syntax like user=domain\user */ - domain_name = check_for_domain(&user_name); + if(got_domain == 0) + domain_name = check_for_domain(&user_name); strncat(options,",user=",6); strcat(options,user_name); } diff --git a/source/client/umount.cifs.c b/source/client/umount.cifs.c index 6e330a42a7e..88a9776b048 100644 --- a/source/client/umount.cifs.c +++ b/source/client/umount.cifs.c @@ -34,9 +34,10 @@ #include #include #include +#include #define UNMOUNT_CIFS_VERSION_MAJOR "0" -#define UNMOUNT_CIFS_VERSION_MINOR "2" +#define UNMOUNT_CIFS_VERSION_MINOR "4" #ifndef UNMOUNT_CIFS_VENDOR_SUFFIX #define UNMOUNT_CIFS_VENDOR_SUFFIX "" @@ -50,6 +51,13 @@ #define MNT_EXPIRE 0x04 #endif +#ifndef MOUNTED_LOCK +#define MOUNTED_LOCK "/etc/mtab~" +#endif +#ifndef MOUNTED_TEMP +#define MOUNTED_TEMP "/etc/mtab.tmp" +#endif + #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDU */ @@ -85,6 +93,7 @@ static void umount_cifs_usage(void) printf("\n\tman 8 umount.cifs\n"); printf("\nTo display the version number of the cifs umount utility:"); printf("\n\t%s -V\n",thisprogram); + printf("\nNote that invoking the umount utility on cifs mounts, can execute /sbin/umount.cifs (if it is present and -i is not specified to umount).\n"); } static int umount_check_perm(char * dir) @@ -92,8 +101,11 @@ static int umount_check_perm(char * dir) int fileid; int rc; - /* presumably can not chdir into the target as we do on mount */ + /* allow root to unmount, no matter what */ + if(getuid() == 0) + return 0; + /* presumably can not chdir into the target as we do on mount */ fileid = open(dir, O_RDONLY | O_DIRECTORY | O_NOFOLLOW, 0); if(fileid == -1) { if(verboseflg) @@ -115,6 +127,73 @@ static int umount_check_perm(char * dir) return rc; } +int remove_from_mtab(char * mountpoint) +{ + int rc = 0; + FILE * org_fd; + FILE * new_fd; + struct mntent * mount_entry; + + /* Do we need to check if it is a symlink to e.g. /proc/mounts + in which case we probably do not want to update it? */ + + /* Do we first need to check if it is writable? */ + + /* BB lock_mtab - the smbumount and mount-utils package appear to lock + in a different incompat. way, and it seems that mount-utils have + changed the way they lock a few times. We should fix this someday + or at least find out how the mount-utils are supposed to handle this */ + + if(verboseflg) + printf("attempting to remove from mtab\n"); + + org_fd = setmntent(MOUNTED, "r"); + + if(org_fd == NULL) { + printf("Can not open %s\n",MOUNTED); + return -EIO; + } + + new_fd = setmntent(MOUNTED_TEMP,"w"); + if(new_fd == NULL) { + printf("Can not open temp file %s", MOUNTED_TEMP); + endmntent(org_fd); + return -EIO; + } + + /* BB fix so we only remove the last entry that matches BB */ + while((mount_entry = getmntent(org_fd)) != NULL) { + if(strcmp(mount_entry->mnt_dir, mountpoint) != 0) { + addmntent(new_fd, mount_entry); + } else { + if(verboseflg) + printf("entry not copied (removed)\n"); + } + + } + + if(verboseflg) + printf("done updating tmp file\n"); + rc = fchmod (fileno (new_fd), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); + if(rc < 0) { + printf("error %s changing mode of %s\n", strerror(errno), + MOUNTED_TEMP); + } + endmntent(new_fd); + + rc = rename(MOUNTED_TEMP, MOUNTED); + + if(rc < 0) { + printf("failure %s renaming %s to %s\n",strerror(errno), + MOUNTED_TEMP, MOUNTED); + return -EIO; + } + + /* BB unlock_mtab - unlink(MOUNTED_LOCK) */ + + return rc; +} + int main(int argc, char ** argv) { int c; @@ -122,10 +201,8 @@ int main(int argc, char ** argv) int flags = 0; int nomtab = 0; int retry_remount = 0; - struct mntent mountent; struct statfs statbuf; char * mountpoint; - FILE * pmntfile; if(argc && argv) { thisprogram = argv[0]; @@ -238,48 +315,10 @@ int main(int argc, char ** argv) printf("Refer to the umount.cifs(8) manual page (e.g.man 8 umount.cifs)\n"); return -1; } else { - pmntfile = setmntent(MOUNTED, "a+"); - if(pmntfile) { -/* mountent.mnt_fsname = share_name; - mountent.mnt_dir = mountpoint; - mountent.mnt_type = "cifs"; - mountent.mnt_opts = malloc(220); - if(mountent.mnt_opts) { - char * mount_user = getusername(); - memset(mountent.mnt_opts,0,200); - if(flags & MS_RDONLY) - strcat(mountent.mnt_opts,"ro"); - else - strcat(mountent.mnt_opts,"rw"); - if(flags & MS_MANDLOCK) - strcat(mountent.mnt_opts,",mand"); - else - strcat(mountent.mnt_opts,",nomand"); - if(flags & MS_NOEXEC) - strcat(mountent.mnt_opts,",noexec"); - if(flags & MS_NOSUID) - strcat(mountent.mnt_opts,",nosuid"); - if(flags & MS_NODEV) - strcat(mountent.mnt_opts,",nodev"); - if(flags & MS_SYNCHRONOUS) - strcat(mountent.mnt_opts,",synch"); - if(mount_user) { - if(getuid() != 0) { - strcat(mountent.mnt_opts,",user="); - strcat(mountent.mnt_opts,mount_user); - } - free(mount_user); - } - } - mountent.mnt_freq = 0; - mountent.mnt_passno = 0; - rc = addmntent(pmntfile,&mountent); - endmntent(pmntfile); - if(mountent.mnt_opts) - free(mountent.mnt_opts);*/ - } else { - printf("could not update mount table\n"); - } + if(verboseflg) + printf("umount2 succeeded\n"); + if(nomtab == 0) + remove_from_mtab(mountpoint); } return 0; diff --git a/source/include/includes.h b/source/include/includes.h index 09c8e37f3f5..940c15c3ce4 100644 --- a/source/include/includes.h +++ b/source/include/includes.h @@ -867,8 +867,6 @@ extern int errno; #include "idmap.h" -#include "printerdb.h" - #include "client.h" #ifdef WITH_SMBWRAPPER diff --git a/source/include/printerdb.h b/source/include/printerdb.h deleted file mode 100644 index 0e149b025f0..00000000000 --- a/source/include/printerdb.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef _PRINTERDB_H_ -#define _PRINTERDB_H_ -/* - Unix SMB/CIFS implementation. - - PrinterDB headers - - Copyright (C) Guenther Deschner 2004 - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#define SMB_PRINTERDB_INTERFACE_VERSION 1 - -/* TODO: - * use WERROR as general return code - * add a mem_ctx - * discuss with jerry and vl - */ - -enum tdb_files { - TDB_DRIVERS, - TDB_FORMS, - TDB_PRINTERS, - TDB_SECDESC, - TDB_DRIVERSINIT -}; - -/* Filled out by PRINTDB backends */ -struct printerdb_methods { - - time_t (*get_last_update) (int tdb); - BOOL (*set_last_update) (time_t update, int tdb); - - /* Called when backend is first loaded */ - BOOL (*init)( char *params ); - - uint32 (*get_c_setprinter) ( void ); - uint32 (*update_c_setprinter)( BOOL initialize ); - - int (*get_forms)( nt_forms_struct **list ); - int (*write_forms)( nt_forms_struct **list, int number ); - BOOL (*del_form)( char *del_name, WERROR *ret ); - - int (*get_drivers)( fstring **list, const char *short_archi, uint32 version ); - uint32 (*add_driver)( NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver, const char *short_archi ); - WERROR (*get_driver)( NT_PRINTER_DRIVER_INFO_LEVEL_3 **driver, fstring drivername, const char *arch, uint32 version); - BOOL (*del_driver)( const char *short_archi, int version, const char *drivername ); - BOOL (*del_driver_init) (const char *drivername); - - int (*get_printers)(fstring **list); - WERROR (*get_printer)(NT_PRINTER_INFO_LEVEL_2 **info_ptr, const char *sharename); - WERROR (*update_printer)(NT_PRINTER_INFO_LEVEL_2 *info); - WERROR (*del_printer)( const char *sharename ); - - WERROR (*get_secdesc)( TALLOC_CTX *mem_ctx, const char *printername, SEC_DESC_BUF **secdesc_ctr ); - WERROR (*set_secdesc)( TALLOC_CTX *mem_ctx, const char *printername, SEC_DESC_BUF *secdesc_ctr ); - - WERROR (*get_driver_init)(const char *drivername, NT_PRINTER_INFO_LEVEL_2 **info); - uint32 (*update_driver_init)(NT_PRINTER_INFO_LEVEL_2 *info); - - /* Called when backend is unloaded */ - BOOL (*close)(void); - - /* Called to dump backend status */ - void (*status)(void); -}; -#endif /* _PRINTERDB_H_ */ diff --git a/source/include/smb_macros.h b/source/include/smb_macros.h index 46173b12172..d798d4395e1 100644 --- a/source/include/smb_macros.h +++ b/source/include/smb_macros.h @@ -83,6 +83,9 @@ #define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) +/* you must add the following extern declaration to files using this macro + * extern struct current_user current_user; + */ #define FSP_BELONGS_CONN(fsp,conn) do {\ extern struct current_user current_user;\ if (!((fsp) && (conn) && ((conn)==(fsp)->conn) && (current_user.vuid==(fsp)->vuid))) \ @@ -91,6 +94,9 @@ #define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) +/* you must add the following extern declaration to files using this macro + * extern struct current_user current_user; + */ #define CHECK_FSP(fsp,conn) do {\ extern struct current_user current_user;\ if (!FNUM_OK(fsp,conn)) \ diff --git a/source/include/tdbsam2_parse_info.h b/source/include/tdbsam2_parse_info.h deleted file mode 100644 index 35eeaeb2d2c..00000000000 --- a/source/include/tdbsam2_parse_info.h +++ /dev/null @@ -1,2 +0,0 @@ -/* This is an automatically generated file - DO NOT EDIT! */ - diff --git a/source/lib/dummyroot.c b/source/lib/dummyroot.c index 75263ed232e..bd04bd9ee58 100644 --- a/source/lib/dummyroot.c +++ b/source/lib/dummyroot.c @@ -22,8 +22,7 @@ /* Stupid dummy functions required due to the horrible dependency mess in Samba. */ -void become_root(void); -void unbecome_root(void); +#include "includes.h" void become_root(void) { diff --git a/source/lib/dummysmbd.c b/source/lib/dummysmbd.c index 153ca5cd8cf..1b31dff4995 100644 --- a/source/lib/dummysmbd.c +++ b/source/lib/dummysmbd.c @@ -22,7 +22,7 @@ /* Stupid dummy functions required due to the horrible dependency mess in Samba. */ -void decrement_smbd_process_count( void ); +#include "includes.h" void decrement_smbd_process_count( void ) { diff --git a/source/libsmb/clifile.c b/source/libsmb/clifile.c index ebcbf435ef9..90ca98d17eb 100644 --- a/source/libsmb/clifile.c +++ b/source/libsmb/clifile.c @@ -266,8 +266,8 @@ BOOL cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbu sbuf->st_ctime = interpret_long_date(rdata + 16); /* time of last change */ sbuf->st_atime = interpret_long_date(rdata + 24); /* time of last access */ sbuf->st_mtime = interpret_long_date(rdata + 32); /* time of last modification */ - sbuf->st_uid = IVAL(rdata,40); /* user ID of owner */ - sbuf->st_gid = IVAL(rdata,48); /* group ID of owner */ + sbuf->st_uid = (uid_t) IVAL(rdata,40); /* user ID of owner */ + sbuf->st_gid = (gid_t) IVAL(rdata,48); /* group ID of owner */ sbuf->st_mode |= unix_filetype_from_wire(IVAL(rdata, 56)); #if defined(HAVE_MAKEDEV) { diff --git a/source/libsmb/clikrb5.c b/source/libsmb/clikrb5.c index 6cf75006044..e70c2b8beca 100644 --- a/source/libsmb/clikrb5.c +++ b/source/libsmb/clikrb5.c @@ -396,7 +396,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, /* cope with ticket being in the future due to clock skew */ if ((unsigned)credsp->times.starttime > time(NULL)) { time_t t = time(NULL); - int time_offset =(unsigned)credsp->times.starttime-t; + int time_offset =(int)((unsigned)credsp->times.starttime-t); DEBUG(4,("ads_krb5_mk_req: Advancing clock by %d seconds to cope with clock skew\n", time_offset)); krb5_set_real_time(context, t + time_offset + 1, 0); } @@ -405,7 +405,7 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, creds_ready = True; } - DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s) is valid until: (%s - %d)\n", + DEBUG(10,("ads_krb5_mk_req: Ticket (%s) in ccache (%s) is valid until: (%s - %u)\n", principal, krb5_cc_default_name(context), http_timestring((unsigned)credsp->times.endtime), (unsigned)credsp->times.endtime)); diff --git a/source/libsmb/trustdom_cache.c b/source/libsmb/trustdom_cache.c index e63acd18c4f..8c5fb4d9071 100644 --- a/source/libsmb/trustdom_cache.c +++ b/source/libsmb/trustdom_cache.c @@ -320,7 +320,7 @@ void update_trustdom_cache( void ) if ( (last_check = trustdom_cache_fetch_timestamp()) == 0 ) trustdom_cache_store_timestamp(0, now+TRUSTDOM_UPDATE_INTERVAL); - time_diff = now - last_check; + time_diff = (int) (now - last_check); if ( (time_diff > 0) && (time_diff < TRUSTDOM_UPDATE_INTERVAL) ) { DEBUG(10,("update_trustdom_cache: not time to update trustdom_cache yet\n")); diff --git a/source/modules/vfs_fake_perms.c b/source/modules/vfs_fake_perms.c index 740218dcd41..4d10ea5f337 100644 --- a/source/modules/vfs_fake_perms.c +++ b/source/modules/vfs_fake_perms.c @@ -24,6 +24,8 @@ #include "includes.h" +extern struct current_user current_user; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS @@ -33,8 +35,6 @@ static int fake_perms_stat(vfs_handle_struct *handle, connection_struct *conn, c ret = SMB_VFS_NEXT_STAT(handle, conn, fname, sbuf); if (ret == 0) { - extern struct current_user current_user; - if (S_ISDIR(sbuf->st_mode)) { sbuf->st_mode = S_IFDIR | S_IRWXU; } else { @@ -53,8 +53,6 @@ static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd ret = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf); if (ret == 0) { - extern struct current_user current_user; - if (S_ISDIR(sbuf->st_mode)) { sbuf->st_mode = S_IFDIR | S_IRWXU; } else { diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c index 9e89b9cab64..af93bf5197c 100644 --- a/source/nmbd/nmbd.c +++ b/source/nmbd/nmbd.c @@ -27,6 +27,8 @@ int ClientNMB = -1; int ClientDGRAM = -1; int global_nmb_port = -1; +extern BOOL rescan_listen_set; +extern struct in_addr loopback_ip; extern BOOL global_in_nmbd; extern BOOL override_logfile; @@ -196,8 +198,6 @@ static BOOL reload_interfaces(time_t t) static time_t lastt; int n; struct subnet_record *subrec; - extern BOOL rescan_listen_set; - extern struct in_addr loopback_ip; if (t && ((t - lastt) < NMBD_INTERFACES_RELOAD)) return False; lastt = t; diff --git a/source/nsswitch/wb_client.c b/source/nsswitch/wb_client.c index 7e7916b8127..f2cdfbca6b4 100644 --- a/source/nsswitch/wb_client.c +++ b/source/nsswitch/wb_client.c @@ -420,80 +420,4 @@ BOOL winbind_ping( void ) return result == NSS_STATUS_SUCCESS; } -/***********************************************************************/ -#if 0 /* not needed currently since winbindd_acct was added -- jerry */ - -/* Call winbindd to convert SID to uid. Do not allocate */ - -BOOL winbind_sid_to_uid_query(uid_t *puid, const DOM_SID *sid) -{ - struct winbindd_request request; - struct winbindd_response response; - int result; - fstring sid_str; - - if (!puid) - return False; - - /* Initialise request */ - - ZERO_STRUCT(request); - ZERO_STRUCT(response); - - sid_to_string(sid_str, sid); - fstrcpy(request.data.sid, sid_str); - - request.flags = WBFLAG_QUERY_ONLY; - - /* Make request */ - - result = winbindd_request(WINBINDD_SID_TO_UID, &request, &response); - - /* Copy out result */ - - if (result == NSS_STATUS_SUCCESS) { - *puid = response.data.uid; - } - - return (result == NSS_STATUS_SUCCESS); -} - -/* Call winbindd to convert SID to gid. Do not allocate */ - -BOOL winbind_sid_to_gid_query(gid_t *pgid, const DOM_SID *sid) -{ - struct winbindd_request request; - struct winbindd_response response; - int result; - fstring sid_str; - - if (!pgid) - return False; - - /* Initialise request */ - - ZERO_STRUCT(request); - ZERO_STRUCT(response); - - sid_to_string(sid_str, sid); - fstrcpy(request.data.sid, sid_str); - - request.flags = WBFLAG_QUERY_ONLY; - - /* Make request */ - - result = winbindd_request(WINBINDD_SID_TO_GID, &request, &response); - - /* Copy out result */ - - if (result == NSS_STATUS_SUCCESS) { - *pgid = response.data.gid; - } - - return (result == NSS_STATUS_SUCCESS); -} - -#endif /* JERRY */ - -/***********************************************************************/ diff --git a/source/pam_smbpass/pam_smb_auth.c b/source/pam_smbpass/pam_smb_auth.c index d0dca6fa920..74645564d48 100644 --- a/source/pam_smbpass/pam_smb_auth.c +++ b/source/pam_smbpass/pam_smb_auth.c @@ -82,7 +82,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, /* Get a few bytes so we can pass our return value to pam_sm_setcred(). */ - ret_data = malloc(sizeof(int)); + ret_data = SMB_MALLOC_P(int); /* get the username */ retval = pam_get_user( pamh, &name, "Username: " ); diff --git a/source/pam_smbpass/pam_smb_passwd.c b/source/pam_smbpass/pam_smb_passwd.c index bef587a916c..8149bc12003 100644 --- a/source/pam_smbpass/pam_smb_passwd.c +++ b/source/pam_smbpass/pam_smb_passwd.c @@ -169,7 +169,7 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags, /* tell user what is happening */ #define greeting "Changing password for " - Announce = (char *) malloc(sizeof(greeting)+strlen(user)); + Announce = SMB_MALLOC_ARRAY(char, sizeof(greeting)+strlen(user)); if (Announce == NULL) { _log_err(LOG_CRIT, "password: out of memory"); pdb_free_sam(&sampass); diff --git a/source/pam_smbpass/support.c b/source/pam_smbpass/support.c index 8a0432c8550..f5682480eba 100644 --- a/source/pam_smbpass/support.c +++ b/source/pam_smbpass/support.c @@ -238,7 +238,7 @@ char * smbpXstrDup( const char *x ) register int i; for (i = 0; x[i]; ++i); /* length of string */ - if ((new = malloc(++i)) == NULL) { + if ((new = SMB_MALLOC_ARRAY(char, ++i)) == NULL) { i = 0; _log_err( LOG_CRIT, "out of memory in smbpXstrDup" ); } else { @@ -344,7 +344,7 @@ int _smb_verify_password( pam_handle_t * pamh, SAM_ACCOUNT *sampass, } } - data_name = (char *) malloc( sizeof(FAIL_PREFIX) + strlen( name )); + data_name = SMB_MALLOC_ARRAY(char, sizeof(FAIL_PREFIX) + strlen( name )); if (data_name == NULL) { _log_err( LOG_CRIT, "no memory for data-name" ); } @@ -379,8 +379,7 @@ int _smb_verify_password( pam_handle_t * pamh, SAM_ACCOUNT *sampass, /* get a failure recorder */ - new = (struct _pam_failed_auth *) - malloc( sizeof(struct _pam_failed_auth) ); + new = SMB_MALLOC_P( struct _pam_failed_auth ); if (new != NULL) { diff --git a/source/smbd/dir.c b/source/smbd/dir.c index f3ee6310a7f..d66d1601fbf 100644 --- a/source/smbd/dir.c +++ b/source/smbd/dir.c @@ -1079,7 +1079,6 @@ const char *ReadDirName(struct smb_Dir *dirp, long *poffset) struct name_cache_entry *e; dirp->offset = SMB_VFS_TELLDIR(conn, dirp->dir); dirp->name_cache_index = (dirp->name_cache_index+1) % NAME_CACHE_SIZE; - e = &dirp->name_cache[dirp->name_cache_index]; SAFE_FREE(e->name); e->name = SMB_STRDUP(n); diff --git a/source/smbd/fake_file.c b/source/smbd/fake_file.c index b60b83f55fd..59ddb60db5e 100644 --- a/source/smbd/fake_file.c +++ b/source/smbd/fake_file.c @@ -20,6 +20,8 @@ #include "includes.h" +extern struct current_user current_user; + /**************************************************************************** Open a file with a share mode. ****************************************************************************/ @@ -29,7 +31,6 @@ files_struct *open_fake_file_shared1(enum FAKE_FILE_TYPE fake_file_type, connect int share_mode,int ofun, uint32 new_dos_attr, int oplock_request, int *Access,int *action) { - extern struct current_user current_user; int flags=0; files_struct *fsp = NULL; diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c index 45a4ee01159..9b8df98fd56 100644 --- a/source/smbd/oplock.c +++ b/source/smbd/oplock.c @@ -31,6 +31,9 @@ static int32 level_II_oplocks_open = 0; BOOL global_client_failed_oplock_break = False; BOOL global_oplock_break = False; +extern struct timeval smb_last_time; +extern uint32 global_client_caps; +extern struct current_user current_user; extern int smb_read_error; static struct kernel_oplocks *koplocks; @@ -518,8 +521,6 @@ static void prepare_break_message(char *outbuf, files_struct *fsp, BOOL level2) static void wait_before_sending_break(BOOL local_request) { - extern struct timeval smb_last_time; - if(local_request) { struct timeval cur_tv; long wait_left = (long)lp_oplock_break_wait_time(); @@ -603,7 +604,6 @@ static files_struct *initial_break_processing(SMB_DEV_T dev, SMB_INO_T inode, un static BOOL oplock_break_level2(files_struct *fsp, BOOL local_request) { - extern uint32 global_client_caps; char outbuf[128]; SMB_DEV_T dev = fsp->dev; SMB_INO_T inode = fsp->inode; @@ -676,8 +676,6 @@ static BOOL oplock_break_level2(files_struct *fsp, BOOL local_request) static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_id, BOOL local_request) { - extern uint32 global_client_caps; - extern struct current_user current_user; char *inbuf = NULL; char *outbuf = NULL; files_struct *fsp = NULL; diff --git a/source/smbd/oplock_linux.c b/source/smbd/oplock_linux.c index 30458eab31d..6d1bc64ce10 100644 --- a/source/smbd/oplock_linux.c +++ b/source/smbd/oplock_linux.c @@ -138,7 +138,8 @@ static BOOL linux_oplock_receive_message(fd_set *fds, char *buffer, int buffer_l fsp = file_find_fd(fd); fd_pending_array[0] = (SIG_ATOMIC_T)-1; if (signals_received > 1) - memmove((void *)&fd_pending_array[0], (void *)&fd_pending_array[1], + memmove(CONST_DISCARD(void *, &fd_pending_array[0]), + CONST_DISCARD(void *, &fd_pending_array[1]), sizeof(SIG_ATOMIC_T)*(signals_received-1)); signals_received--; /* now we can receive more signals */ diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c index 1a73fdf2223..008f212c2cb 100644 --- a/source/smbd/quotas.c +++ b/source/smbd/quotas.c @@ -923,7 +923,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB #else -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include #include #elif AIX @@ -933,12 +933,12 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB #define dqb_curfiles dqb_curinodes #define dqb_fhardlimit dqb_ihardlimit #define dqb_fsoftlimit dqb_isoftlimit -#else /* !__FreeBSD__ && !AIX && !__OpenBSD__ */ +#else /* !__FreeBSD__ && !AIX && !__OpenBSD__ && !__DragonFly__ */ #include #include #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) #include #include @@ -1119,7 +1119,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB int r; struct dqblk D; uid_t euser_id; -#if !defined(__FreeBSD__) && !defined(AIX) && !defined(__OpenBSD__) +#if !defined(__FreeBSD__) && !defined(AIX) && !defined(__OpenBSD__) && !defined(__DragonFly__) char dev_disk[256]; SMB_STRUCT_STAT S; @@ -1136,7 +1136,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB return (False); #endif /* ifdef HPUX */ -#endif /* !defined(__FreeBSD__) && !defined(AIX) && !defined(__OpenBSD__) */ +#endif /* !defined(__FreeBSD__) && !defined(AIX) && !defined(__OpenBSD__) && !defined(__DragonFly__) */ euser_id = geteuid(); @@ -1149,11 +1149,11 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB restore_re_uid(); #else -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) { /* FreeBSD patches from Marty Moll */ gid_t egrp_id; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) SMB_DEV_T devno; struct statfs *mnts; SMB_STRUCT_STAT st; @@ -1180,7 +1180,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB save_re_uid(); set_effective_uid(0); -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) if (strcmp(mnts[i].f_fstypename,"nfs") == 0) { BOOL retval; retval = nfs_quotas(mnts[i].f_mntfromname,euser_id,bsize,dfree,dsize); @@ -1208,17 +1208,17 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB return False; r= quotactl(path,QCMD(Q_GETQUOTA,USRQUOTA),euser_id,(char *) &D); restore_re_uid(); -#else /* !__FreeBSD__ && !AIX && !__OpenBSD__ */ +#else /* !__FreeBSD__ && !AIX && !__OpenBSD__ && !__DragonFly__ */ r=quotactl(Q_GETQUOTA, dev_disk, euser_id, &D); -#endif /* !__FreeBSD__ && !AIX && !__OpenBSD__ */ +#endif /* !__FreeBSD__ && !AIX && !__OpenBSD__ && !__DragonFly__ */ #endif /* HPUX */ /* Use softlimit to determine disk space, except when it has been exceeded */ -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) *bsize = DEV_BSIZE; -#else /* !__FreeBSD__ && !__OpenBSD__ */ +#else /* !__FreeBSD__ && !__OpenBSD__ && !__DragonFly__ */ *bsize = 1024; -#endif /*!__FreeBSD__ && !__OpenBSD__ */ +#endif /*!__FreeBSD__ && !__OpenBSD__ && !__DragonFly__ */ if (r) { @@ -1241,7 +1241,7 @@ BOOL disk_quotas(const char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB return(False); /* Use softlimit to determine disk space, except when it has been exceeded */ if ((D.dqb_curblocks>D.dqb_bsoftlimit) -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) ||((D.dqb_curfiles>D.dqb_fsoftlimit) && (D.dqb_fsoftlimit != 0)) #endif ) { diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c index 2e23bdcc4e5..a0544c31b7b 100644 --- a/source/smbd/trans2.c +++ b/source/smbd/trans2.c @@ -23,6 +23,7 @@ #include "includes.h" +extern int max_send; extern enum protocol_types Protocol; extern int smb_read_error; extern int global_oplock_break; @@ -574,7 +575,6 @@ static int send_trans2_replies(char *outbuf, global struct. These different max_xmit variables should be merged as this is now too confusing */ - extern int max_send; int data_to_send = datasize; int params_to_send = paramsize; int useable_space; diff --git a/source/tdb/tdbbackup.c b/source/tdb/tdbbackup.c index 1a0e1c1588f..f49cd339c79 100644 --- a/source/tdb/tdbbackup.c +++ b/source/tdb/tdbbackup.c @@ -69,6 +69,9 @@ #include "tdb.h" #include "tdbback.h" +extern int optind; +extern char *optarg; + /* see if one file is newer than another */ @@ -100,8 +103,6 @@ static void usage(void) int c; int verify = 0; const char *suffix = ".bak"; - extern int optind; - extern char *optarg; while ((c = getopt(argc, argv, "vhs:")) != -1) { switch (c) { diff --git a/source/tdb/tdbutil.c b/source/tdb/tdbutil.c index 43613c1e7cd..47f1bb2dc24 100644 --- a/source/tdb/tdbutil.c +++ b/source/tdb/tdbutil.c @@ -43,7 +43,7 @@ static void gotalarm_sig(void) TDB_DATA make_tdb_data(const char *dptr, size_t dsize) { TDB_DATA ret; - ret.dptr = dptr; + ret.dptr = CONST_DISCARD(char *, dptr); ret.dsize = dsize; return ret; } @@ -62,7 +62,7 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key, /* Allow tdb_chainlock to be interrupted by an alarm. */ int ret; gotalarm = 0; - tdb_set_lock_alarm(&gotalarm); + tdb_set_lock_alarm(CONST_DISCARD(sig_atomic_t *, &gotalarm)); if (timeout) { CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); diff --git a/source/utils/net_lookup.c b/source/utils/net_lookup.c index 7e5f12da454..9ddfe625081 100644 --- a/source/utils/net_lookup.c +++ b/source/utils/net_lookup.c @@ -193,7 +193,7 @@ static int net_lookup_kdc(int argc, const char **argv) } if (argc>0) { - realm.data = (krb5_pointer) argv[0]; + realm.data = CONST_DISCARD(krb5_pointer, argv[0]); realm.length = strlen(argv[0]); } else if (lp_realm() && *lp_realm()) { realm.data = (krb5_pointer) lp_realm(); @@ -209,7 +209,7 @@ static int net_lookup_kdc(int argc, const char **argv) realm.length = strlen(realm.data); } - rc = krb5_locate_kdc(ctx, &realm, &addrs, &num_kdcs, 0); + rc = krb5_locate_kdc(ctx, &realm, (struct sockaddr **) &addrs, &num_kdcs, 0); if (rc) { DEBUG(1, ("krb5_locate_kdc failed (%s)\n", error_message(rc))); return -1; diff --git a/source/utils/ntlm_auth.c b/source/utils/ntlm_auth.c index 0468b671afa..fcaad18ef60 100644 --- a/source/utils/ntlm_auth.c +++ b/source/utils/ntlm_auth.c @@ -1738,8 +1738,8 @@ enum { { "lm-response", 0, POPT_ARG_STRING, &hex_lm_response, OPT_LM, "LM Response to the challenge (HEX encoded)"}, { "nt-response", 0, POPT_ARG_STRING, &hex_nt_response, OPT_NT, "NT or NTLMv2 Response to the challenge (HEX encoded)"}, { "password", 0, POPT_ARG_STRING, &opt_password, OPT_PASSWORD, "User's plaintext password"}, - { "request-lm-key", 0, POPT_ARG_NONE, &request_lm_key, OPT_LM_KEY, "Retreive LM session key"}, - { "request-nt-key", 0, POPT_ARG_NONE, &request_user_session_key, OPT_USER_SESSION_KEY, "Retreive User (NT) session key"}, + { "request-lm-key", 0, POPT_ARG_NONE, &request_lm_key, OPT_LM_KEY, "Retrieve LM session key"}, + { "request-nt-key", 0, POPT_ARG_NONE, &request_user_session_key, OPT_USER_SESSION_KEY, "Retrieve User (NT) session key"}, { "diagnostics", 0, POPT_ARG_NONE, &diagnostics, OPT_DIAGNOSTICS, "Perform diagnostics on the authentictaion chain"}, { "require-membership-of", 0, POPT_ARG_STRING, &require_membership_of, OPT_REQUIRE_MEMBERSHIP, "Require that a user be a member of this group (either name or SID) for authentication to succeed" }, POPT_COMMON_SAMBA -- 2.11.4.GIT