summaryrefslogtreecommitdiffstats
path: root/source/lib/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Added BROKEN_NIS_INCLUDE fix here also.Jeremy Allison1998-12-301-6/+28
| | | | Jeremy.
* lib/signal.c: Added CatchChildLeaveStatus() call needed in smbd/open.c and ↵Jeremy Allison1998-12-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | smbd/chgpasswd.c. smbd/chgpasswd.c smbd/open.c: Ensure that we replace SIGCLD handler with CatchChildLeaveStatus() *before* we expect to reap a child status - and reset it to CatchChild() after we've done the sys_waitpid(). The original CatchChild() code would eat the status code from the zombie in the signal handler, meaning that the sys_waitpid() calls in check_access_allowed_for_current_user() and chgpasswd would never return a status. smbd/open.c: smbd/reply.c: smbd/close.c: Check error return on close() calls - ensure a valid error return is sent back to the client. This catches the "file truncated" bug when a user has run out of quota (or space) and the ENOSPC error is returned on the *close()* call, not the write() (eg. on an nfs mounted drive). smbd/fileio.c: Added check for ESPIPE on sys_lseek() in file_seek() to allow people to use Windows clients to communicate with UNIX fifo's (like they could in 1.9.18). Jeremy.
* Fixed issues with client wildcards. It turns out that NT matchesJeremy Allison1998-12-231-4/+21
| | | | | | | wildcards against both long and short filenames in a trans2 wildcard match. This fix gets us closer to NT compatibility (still not entirely there yet.... one more issue I know about to fix....). Jeremy.
* Rather large (I'm afraid) tidyup of the setuid handling code.Jeremy Allison1998-12-221-53/+0
| | | | | | | | | | | | | | | | | | | | All setuid code now resides in the one module lib/util_sec.c. The interfaces this module exports are : void gain_root_privilage(void); - Set real/eff/saved uid's to 0. void gain_root_group_privilage(void); - Set real/eff/saved gid's to 0. int set_effective_uid(uid_t uid); - Set eff uid *only* to given value. int set_effective_gid(gid_t gid); - Set eff gid *only* to given value. BOOL become_user_permanently(uid_t uid, gid_t gid); - Set real/eff/saved uid's and gid's to uid and gid permanently - with no way back to root. Most of the quota code now uses these calls (except for a few special cases). smbd/chgpasswd.c: Ensured the dochild exits in the fork()'d child. libsmb/nmblib.c: Fix from Jasper for memory leak. Jeremy.
* acconfig.h configure configure.in include/config.h.inJeremy Allison1998-12-151-3/+6
| | | | | | | | lib/system.c script/mkproto.awk include/includes.h: Added sys_readdir that wraps readdir64. lib/util.c: Changed gethostname() to use sizeof(hostname) as the second arg for buffer size. Jeremy.
* Fixed file descriptor limit code for AIX 4.x. AIX doesn't support theJeremy Allison1998-12-111-6/+22
| | | | | fd limits and always returns RLIM_INFINITY for a RLIMIT_NOFILE query. Jeremy.
* HPUX fix. This looks like a big change but isn't actually, most of theJeremy Allison1998-12-101-2/+2
| | | | | | | | | | | | | | | | changes are bzero -> memset as the compiler on HPUX is very picky about bzero (probably a strange define). The significant changes are in configure.in, to fix the HPUX shadow.h problem and also move the large file support to the correct place. passdb/pass_check.c: Added includes for KRB5, DCE and AFS if requested in autoconf. tests/trapdoor.c: Fix to use setresuid and setresgid if defined. The rest of the changes are bzero -> memset. Jeremy.
* locking mask fixes from head branchAndrew Tridgell1998-12-071-2/+3
|
* Samba 2.0 wasn't building on Linux-alpha - so I addedJeremy Allison1998-12-031-1/+1
| | | | | | | | | HAVE_SETRESGID and HAVE_SETRESGID_DECL defines, based on the HAVE_SETRESUID checks. I also updated the places that setresgid was being called based on HAVE_SETRESUID being defined and made sure *both* were defined before allowing the call. Jeremy.
* config.guess: UNIXWARE fix.Jeremy Allison1998-12-031-3/+21
| | | | | | | | lib/util.c: Debug messages for getrlim/setrlim calls. libsmb/clientgen.c: Added session redirect code back in. smbd/nttrans.c smbd/pipes.c: Correct fix for NT printer problem - catches openX as well as nttrans open. Jeremy.
* In my changes prevously to the dos_xxx calls I missed dos_readdir andJeremy Allison1998-11-251-2/+1
| | | | | friends. Jeremy.
* Added lib/doscalls.c : This file collects all the calls that use dos_to_unix()Jeremy Allison1998-11-241-231/+71
| | | | | | | | | | | | | | | | | | | to map filenames before accessing the UNIX filesystem. The other changes are to make the code that previously allways called the ambiguous functions (such as file_size(), that internally called dos_to_unix()) to be unambiguous. For example: file_size() becomes "dos_file_size()", that calls dos_to_unix(), and file_size(), that does not. It is now very explicit when we are calling a dos mapping call and when we are not. Also added string_to_sid unsigned fix by adding the strtoul from libg++ code into lib/replace.c and testing for strtoul in configure.in. Jeremy.
* Fixed gcc isdigit warning.Jeremy Allison1998-11-241-2/+2
| | | | Jeremy.
* Changed (most) open()/fopen()/creat()/mmap() calls to use sys_XXX() instead.Jeremy Allison1998-11-171-3/+3
| | | | | | Needed as in the 64 bit file spec new open types are needed on many OS's to be able to seek past 32bits. Jeremy.
* extracted the password change code from smbpasswd and used it in swatAndrew Tridgell1998-11-121-0/+53
| | | | instead of opening pipes and other horrible stuff.
* largely rewrote smbpasswd so that the code is understandable. ThisAndrew Tridgell1998-11-121-1/+1
| | | | | | | | | | | | | should allow us to call a function in swat rather than piping to smbpasswd. while doing this I also fixed quite a few "const char *" versus "char *" issues that cropped up while using const to track down bugs in the code. This led to changes in several generic functions. The smbpasswd changes should be correct but they have not been extensively tested. At least if I have introduced bugs then we should be able to fix them more easily than before.
* changed syntax of registry commands so keys can start with HKLM or HKU.Luke Leighton1998-11-111-13/+55
| | | | sorted lookupsids command
* util functions split into relevant modules, first pass.Luke Leighton1998-11-101-1992/+99
|
* Makefile.in: Removed rpc_server/srv_ldap_helpers.c per J.F.'s instructions.Jeremy Allison1998-11-091-1/+1
| | | | | | | | | | | | | client/client.c: client/clitar.c: include/client.h: smbwrapper/smbw_dir.c: smbwrapper/smbw_stat.c: smbwrapper/smbw.c: lib/util.c: Converted all use of 'mode' to uint16. smbd/quotas.c: Fixed stupid comment bug I put in there :-(. printing/printing.c: Fix from J.F. to new code. Jeremy.
* use abort() instead of exit() in smb_panic()Andrew Tridgell1998-10-281-1/+1
| | | | | the reason we don't return() here is that smb_panic() is used not just for segv but also for detected errors (such as buffer overflows)
* include/smb.h: Added #defines for lots of things - makes our code a *lot* ↵Jeremy Allison1998-10-231-1/+1
| | | | | | | | | | | | | easier to read. lib/util.c: Fixed Luke's set_first_token() function - should return void. smbd/close.c: Move delete_on_close into file_fd_struct structure. smbd/ipc.c: Changed local_machine back to fstring. smbd/nttrans.c: Use defines for mapping share modes. smbd/open.c: Move delete_on_close into file_fd_struct structure, added code for ALLOW_SHARE_DELETE. smbd/reply.c: Use defines for mapping share modes. smbd/trans2.c: Move delete_on_close into file_fd_struct structure. Jeremy.
* rpctorture commandLuke Leighton1998-10-221-0/+5
|
* Fixed bug found by John Blair where trim_string wasn'tJeremy Allison1998-10-201-7/+89
| | | | | correctly trimming trailing multibyte code page strings. Jeremy.
* some quite important bug-fixes i missed because i transferred the wrongLuke Leighton1998-10-201-1/+3
| | | | | | | | | | | | | | smb.tgz file from my portable. particularly the call to mem_data followed by a realloc of that data in cli_pipe.c's rpc_read() function. smbd responses now use p->rdata_i which is a faked-up pointer into p->rdata's response data. rdata can be very long; rdata_i is limited to point to no more than max_tsize - 0x18 in length. this will make it an almost trivial task to add the encrypted rpc headers after rdata_i, and mem_buf_copy will cope admirably with rhdr chained to rdata_i chained to auth_verifier etc etc...
* - dce/rpc codeLuke Leighton1998-10-191-16/+4
| | | | | | | | | | | | | | | | | | | - removed debug info in struni2 and unistr2 (security risk) - rpc_pipe function was getting pointer to data then calling realloc *dur* - password check function, the start of "credential checking", user, wks, domain, pass as the credentials (not just user,pass which is incorrect in a domain context) - cli_write needs to return ssize_t not size_t, because total can be -1 if the write fails. - fixed signed / unsigned warnings (how come i don't get those any more when i compile with gcc???) - nt password change added in smbd. yes, jeremy, i verified that the SMBtrans2 version still works.
* removed an incorrect commentAndrew Tridgell1998-10-191-4/+0
|
* Fixed sys_lseek and seek_file calls so all returnsJeremy Allison1998-10-181-2/+3
| | | | | are *checked* :-). Jeremy.
* Re-added code to tell the user how many open files theyJeremy Allison1998-10-161-5/+7
| | | | | have. Needed for server diagnosis purposes... Jeremy.
* - fixed cast warningsAndrew Tridgell1998-10-051-11/+13
| | | | - ignore *.po32 files
* added a function set_maxfiles() to set our file rlimit to the maxAndrew Tridgell1998-10-051-0/+23
| | | | possible and return the max.
* more solaris 2.5 fixups. It now seems to be working pretty well.Andrew Tridgell1998-10-041-0/+1
|
* use *SMBSERVER convention in smbwrapper to allow us to connect toAndrew Tridgell1998-10-041-1/+1
| | | | servers that we don't know the netbios name of.
* added support for printing via smbwrapperAndrew Tridgell1998-10-041-1/+11
| | | | | | You can print using "cp filename /smb/SERVER/PRINTER/jobname" You can list the current printqueue using ls
* added simple device/inode number support based on a checksum of theAndrew Tridgell1998-10-031-1/+1
| | | | filename
* fixed a bug in name_len() (thanks to kooros@kooros.netrack.net)Andrew Tridgell1998-10-031-7/+7
|
* added unlink() and rename() support to smbwrapperAndrew Tridgell1998-10-031-1/+1
|
* - ignore *.p filesAndrew Tridgell1998-10-031-1/+1
| | | | - make msleep() non-static
* Got very strict about the differences and uses ofJeremy Allison1998-09-291-5/+9
| | | | | | | uid_t, gid_t and vuid. Added sys_getgroups() to get around the int * return problem. Set correct datatypes for all uid, gid and vuid variables. Jeremy.
* Fixed problems found in lint pass over the old code by <cpeterso@microsoft.com>.Jeremy Allison1998-09-281-4/+7
| | | | | These were the problems that still existed in the 2.0 branch. Jeremy.
* Changes to test in configure if capabilities are enabled on a system.Jeremy Allison1998-09-281-2/+2
| | | | | | | | | | Changes to get Samba to compile cleanly with the IRIX compiler with the options : -fullwarn -woff 1209,1174 (the -woff options are to turn off warnings about unused function parameters and controlling loop expressions being constants). Split prototype generation as we hit a limit in IRIX nawk. Removed "." code in smbd/filename.c (yet again :-). Jeremy.
* Makefile.in: Fixed bug with continuation line causing proto to fail.Jeremy Allison1998-09-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added $(PROGS) $(SPROGS) as targets for make clean. acconfig.h: Added HAVE_IRIX_SPECIFIC_CAPABILITIES. configure.in: Added sys/capability.h header check. Added function checks for srandom random srand rand. Added HAVE_IRIX_SPECIFIC_CAPABILITIES test. includes.h: Added #include <sys/capability.h>. ntdomain.h: Moved struct acct_info into here from smb.h smb.h: Added KERNEL_OPLOCK_CAPABILITY define. Moved enum action_type into rpcclient.h Moved struct cli_state into client.h Moved struct nt_client_info, struct tar_client_info, struct client_info into rpcclient.h lib/genrand.c: Changed to use sys_random() & friends. lib/smbrun.c: Lose capabilities after fork. lib/system.c: Added set_process_capability(), set_inherited_process_capability() sys_random(), sys_srandom(). lib/util.c: Added Ander's EFBIG lock check to fcntl_lock for 64 bit access to an 32 bit mounted NFS filesystem. nmbd/nmbd.c: Changed to use sys_random() & friends. nmbd/nmbd_browsesync.c: Changed to use sys_random() & friends. passdb/ldap.c: Missed one pdb_encode_acct_ctrl call. passdb/passdb.c: Changed to Ander's code for ' ' characters. passdb/smbpass.c: Added Ander's code to reset ACB_PWNOTREQ. script/mkproto.awk: Added 'long' to prototypes. smbd/chgpasswd.c: Lose capabilities after fork. smbd/open.c: Do the mmap *after* the kernel oplock. smbd/oplock.c: Removed stub code from kernel oplock path. Added set_process_capability(), set_inherited_process_capability() calls. smbd/reply.c: Initialize count = 0, offset = 0. smbd/server.c: Added set_process_capability(), set_inherited_process_capability() calls. tests/summary.c: Ensure we have RANDOM or RAND. utils/smbpasswd.c: Added Ander's code to reset ACB_PWNOTREQ. utils/torture.c: Changed to use sys_random() & friends. Jeremy.
* added rpcclient programLuke Leighton1998-09-251-0/+40
|
* First cut at kernel oplocks. This should have no effect unless runninJeremy Allison1998-09-231-218/+0
| | | | | | | | | on a machine that supports them in autoconf. Move various functions out of lib/util.c into smbd/process.c and smbd/oplock.c where they belong. Jeremy.
* Remove some byte-copying code in unix_format() that did nothing exceptJeremy Allison1998-09-191-8/+0
| | | | | | slow down my benchmark :-). Jeremy.
* got rid of some #ifdef LARGE_XXXX stuff and got rid of non-portable LLAndrew Tridgell1998-09-181-15/+4
| | | | suffix from some constants.
* configure configure.in: Added checks for statvfs64. Last bit of 64 bit ↵Jeremy Allison1998-09-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | widening (I hope :-). include/config.h.in: Added #undef STAT_STATVFS64. include/includes.h: Added SMB_STRUCT_STATVFS type, Changed SMB_BIG_INTEGER to SMB_BIG_UINT and SMB_BIG_INT types. include/smb.h: Added flag defines from CIFS spec. lib/debug.c: Fixed one more mode_t issue. lib/system.c: Added sys_statvfs wrapper. lib/util.c: Changed trim_string to use size_t. param/loadparm.c: Moved "blocking locks" into locking section. Alphabetised locking options. Question - shuld we do this for all options ? passdb/ldap.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/nispass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/smbpass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. smbd/dfree.c: Changed to use 64 bit types if available. Moved to use unsigned types. smbd/dosmode.c: Fixed one more mode_t issue. smbd/negprot.c: Changed literals to be FLAG_ #defines. smbd/nttrans.c: Removed dead code. smbd/open.c: Changed disk_free call. smbd/process.c: Changed literals to be FLAG_ #defines. smbd/reply.c: Changed disk_free call. smbd/trans2.c: Fixed but in SMB_QUERY_FS_VOLUME_INFO call. Was using UNICODE - should use ascii. tests/summary.c: Added STAT_STATVFS64 check. Jeremy.
* Removed hideous inefficiencies in old trim_string code. This was makingJeremy Allison1998-09-151-15/+22
| | | | | calls to strlen() a profiling hotspot. Jeremy.
* Added ssize_t to configure code.Jeremy Allison1998-09-111-102/+105
| | | | | | | | | | | Got 'religion' about using size_t and ssize_t for read/write stuff as part of the code to expose 64 bits to the client. This checkin does all the 'easy' stuff - such as all the read/write/lock calls - but now comes the harder parts (open & friends) and all the file enquiry functions..... Jeremy.
* ahh, the joy of deleting large chunks of code that someone else hasAndrew Tridgell1998-09-051-13/+0
| | | | | | | | painstakingly put in :) This gets rid of most of the #ifdef LARGE_SMB_INO_T ifdefs around DEBUG() statements. We just use %.0f in all cases. Makes the code a bit easier to read :)
* tridge the destroyer returns!Andrew Tridgell1998-09-051-168/+30
| | | | | | | | | | | | | | | | | | | | | | prompted by the interpret_security() dead code that Jean-Francois pointed out I added a make target "finddead" that finds potentially dead (ie. unused) code. It spat out 304 function names ... I went through these are deleted many of them, making others static (finddead also reports functions that are used only in the local file). in doing this I have almost certainly deleted some useful code. I may have even prevented compilation with some compile options. I apologise. I decided it was better to get rid of this code now and add back the one or two functions that are needed than to keep all this baggage. So, if I have done a bit too much "destroying" then let me know. Keep the swearing to a minimum :) One bit I didn't do is the ubibt code. Chris, can you look at that? Heaps of unused functions there. Can they be made static?