about summary refs log tree commit diff
path: root/src/misc
Commit message (Collapse)AuthorAgeFilesLines
* make crypt return an unmatchable hash rather than NULL on failureRich Felker2012-08-091-5/+2
| | | | | | | | | | | | | | | | unfortunately, a large portion of programs which call crypt are not prepared for its failure and do not check that the return value is non-null before using it. thus, always "succeeding" but giving an unmatchable hash is reportedly a better behavior than failing on error. it was suggested that we could do this the same way as other implementations and put the null-to-unmatchable translation in the wrapper rather than the individual crypt modules like crypt_des, but when i tried to do it, i found it was making the logic in __crypt_r for keeping track of which hash type we're working with and whether it succeeded or failed much more complex, and potentially error-prone. the way i'm doing it now seems to have essentially zero cost, anyway.
* fix missing static in getusershell (namespace pollution)Rich Felker2012-08-021-1/+1
|
* replace old and ugly crypt implementationRich Felker2012-06-293-2574/+1055
| | | | | | | | | | | | | | | | | | | | | | | | | the new version is largely the work of Solar Designer, with minor changes for integration with musl. compared to the old code, text size is reduced by about 7k, stack space usage by about 70k, and performance is greatly improved by avoiding expensive calculation of constant tables on each run. this version also adds support for extended des-based password hashes, which allow for unlimited key (password) length and configurable iteration counts. i've also published the interface for crypt_r in a new crypt.h header. especially since this is not a standard interface, i did not feel compelled to match the glibc abi for the crypt_data structure. the glibc structure is way too big to allocate on the stack; in fact it's so big that the first usage may cause the main thread to exceed its pre-committed stack size of 128k and thus could cause the program to crash even on systems with overcommit disabled. the only legitimate use of crypt_data for crypt_r is to store the hash string to return, so i've reserved 256 bytes, which should be more than sufficient (longest known password hashes are ~60 characters, and beyond that is possibly even exceeding some implementations' passwd file field size limit).
* fix ptsname_r to conform to the upcoming posix requirementsRich Felker2012-06-202-4/+13
| | | | it should return the error code rather than 0/-1 and setting errno.
* add isastream (obsolete STREAMS junk)Rich Felker2012-05-061-0/+7
| | | | | | apparently some packages see stropts.h and want to be able to use this. the implementation checks that the file descriptor is valid by using fcntl/F_GETFD so it can report an error if not (as specified).
* implement stub versions of sched_*Rich Felker2012-05-031-10/+0
| | | | | these actually work, but for now they prohibit actually setting priority levels and report min/max priority as 0.
* ditch the priority inheritance locks; use malloc's version of lockRich Felker2012-04-241-9/+9
| | | | | | | | | | | | | | | | | | | i did some testing trying to switch malloc to use the new internal lock with priority inheritance, and my malloc contention test got 20-100 times slower. if priority inheritance futexes are this slow, it's simply too high a price to pay for avoiding priority inversion. maybe we can consider them somewhere down the road once the kernel folks get their act together on this (and perferably don't link it to glibc's inefficient lock API)... as such, i've switch __lock to use malloc's implementation of lightweight locks, and updated all the users of the code to use an array with a waiter count for their locks. this should give optimal performance in the vast majority of cases, and it's simple. malloc is still using its own internal copy of the lock code because it seems to yield measurably better performance with -O3 when it's inlined (20% or more difference in the contention stress test).
* implement getusershell, etc. legacy functionsRich Felker2012-04-221-0/+33
| | | | | I actually wrote these a month ago but forgot to integrate them. ugly, probably-harmful-to-use functions, but some legacy apps want them...
* add getresuid and getresgid syscall wrappersRich Felker2012-04-222-0/+16
|
* wordexp must set the we_offs entries of we_wordv to null pointersRich Felker2012-04-161-0/+4
|
* fix crash in wordfree if we_offs is not initialized by the callerRich Felker2012-04-161-0/+2
| | | | | | | I'm not sure if it's legal for wordexp to modify this field, but this is the only easy/straightforward fix, and applications should not care. if it's an issue, i can work out a different (but more complex) solution later.
* implement a64l and l64a (legacy xsi stuff)Rich Felker2012-03-011-0/+26
|
* fix (hopefully) PTRACE_TRACEME (command 0) argument handlingRich Felker2012-02-231-2/+2
|
* fix get_current_dir_name behaviorRich Felker2012-02-171-2/+6
|
* add get_current_dir_name functionRich Felker2012-02-171-0/+12
|
* add legacy futimes and lutimes functionsRich Felker2012-01-242-0/+26
| | | | | based on patch by sh4rm4. these functions are deprecated; futimens and utimensat should be used instead in new programs.
* use prlimit syscall for getrlimit/setrlimitRich Felker2012-01-202-4/+14
| | | | | | this allows the full range of 64-bit limit arguments even on 32-bit systems. fallback to the old syscalls on old kernels that don't support prlimit.
* add prlimit syscall wrapperRich Felker2012-01-201-0/+8
|
* alias basename to glibc name for it, to meet abi goalsRich Felker2012-01-181-0/+3
| | | | | | note that regardless of the name used, basename is always conformant. it never takes on the bogus gnu behavior, unlike glibc where basename is nonconformant when declared manually without including libgen.h.
* fix ptrace (maybe)Rich Felker2011-09-161-1/+8
|
* implement ptrace syscall wrapper (untested)Rich Felker2011-09-151-0/+18
|
* remove some stray trailing space charactersRich Felker2011-09-131-1/+1
|
* fix some bugs in setxid and update setrlimit to use __synccallRich Felker2011-07-301-2/+27
| | | | | | | | setrlimit is supposed to be per-process, not per-thread, but again linux gets it wrong. work around this in userspace. not only is it needed for correctness; setxid also depends on the resource limits for all threads being the same to avoid situations where temporarily unlimiting the limit succeeds in some threads but fails in others.
* check for fd exhaustion in forkptyRich Felker2011-07-221-2/+15
| | | | | | | we cannot report failure after forking, so the idea is to ensure prior to fork that fd 0,1,2 exist. this will prevent dup2 from possibly hitting a resource limit and failing in the child process. fcntl rather than dup2 is used prior to forking to avoid race conditions.
* incorrect check for open failure in openpty functionRich Felker2011-07-221-1/+1
| | | | -1, not 0, indicates failure
* wordexp cannot use we_offs unless WRDE_DOOFFS flag is setRich Felker2011-06-251-1/+2
| | | | | | previously, a potentially-indeterminate value from we_offs was being used, resulting in wrong we_wordc and subsequent crashes in the caller.
* fix memory leak on failure in realpathRich Felker2011-06-181-4/+4
|
* add useless, obsolescent function ulimitRich Felker2011-05-291-0/+19
|
* properly create new session/controlling terminal in forkptyRich Felker2011-04-201-1/+4
|
* implement (nonstandard) forkptyRich Felker2011-04-201-0/+22
|
* block cancellation in wordexp, handle more errorsRich Felker2011-04-191-2/+17
|
* avoid malloc of potentially-large string in wordexpRich Felker2011-04-191-10/+28
|
* protect ftw and nftw against cancellationRich Felker2011-04-181-1/+6
|
* protect syslog against cancellationRich Felker2011-04-181-5/+19
| | | | | | these functions are allowed to be cancellation points, but then we would have to install cleanup handlers to avoid termination with locks held.
* minimal realpath implementation using /procRich Felker2011-04-171-0/+43
| | | | | | | clean and simple, but fails when the caller does not have permissions to open the file for reading or when /proc is not available. i may replace this with a full implementation later, possibly leaving this version as an optimization to use when it works.
* remove stupid debug code in wordexpRich Felker2011-04-151-1/+0
|
* implement wordexp. first try, may be buggy. intended to be safe.Rich Felker2011-04-151-0/+128
|
* simplify syslog, add vsyslog interface (nonstandard)Rich Felker2011-04-131-31/+36
| | | | | | | | with datagram sockets, depending on fprintf not to flush the output early was very fragile; the new version simply uses a small fixed-size buffer. it could be updated to dynamic-allocate large buffers if needed, but i can't envision any admin being happy about finding 64kb-long lines in their syslog...
* remove useless SIGPIPE protection from syslogRich Felker2011-04-131-9/+0
| | | | per the standard, SIGPIPE is not generated for SOCK_DGRAM.
* fix syslog (corrected SIGPIPE blocking, and using dgram instead of stream)Rich Felker2011-04-131-10/+8
| | | | | | it actually appears the hacks to block SIGPIPE are probably not necessary, and potentially harmful. if i can confirm this, i'll remove them.
* implement getgrouplist (for initgroups), formerly dummied-out v0.7.8Rich Felker2011-04-131-4/+16
|
* add ptsname_r (nonstandard) and split ptsname (standard) to separate fileRich Felker2011-04-132-11/+16
| | | | this eliminates the ugly static buffer in programs that use ptsname_r.
* move bswap functions to static inline in byteswap.hRich Felker2011-04-122-16/+0
|
* fix broken bswap_32Rich Felker2011-04-121-1/+1
|
* remove ugly warning-suppression hack from crypt - this invokes UB!Rich Felker2011-04-111-1/+1
|
* fix all implicit conversion between signed/unsigned pointersRich Felker2011-03-251-2/+2
| | | | | | | sadly the C language does not specify any such implicit conversion, so this is not a matter of just fixing warnings (as gcc treats it) but actual errors. i would like to revisit a number of these changes and possibly revise the types used to reduce the number of casts required.
* global cleanup to use the new syscall interfaceRich Felker2011-03-208-20/+8
|
* fix compile failure: legacy cuserid needs to define feature testRich Felker2011-02-161-0/+1
|
* fix getrlimit handling on 32-bit systems, and ease porting to 64-bitRich Felker2011-02-151-3/+3
|
* initial check-in, version 0.5.0 v0.5.0Rich Felker2011-02-1226-0/+3194