summaryrefslogtreecommitdiff
path: root/src/misc
AgeCommit message (Collapse)AuthorFilesLines
2012-09-09add setdomainname syscall, fix getdomainname (previously a stub)Rich Felker2-1/+17
2012-09-07cleanup src/linux and src/misc trees, etc.Rich Felker20-2697/+158
previously, it was pretty much random which one of these trees a given function appeared in. they have now been organized into: src/linux: non-POSIX linux syscalls (possibly shard with other nixen) src/legacy: various obsolete/legacy functions, mostly wrappers src/misc: still mostly uncategorized; some misc POSIX, some nonstd src/crypt: crypt hash functions further cleanup will be done later.
2012-09-06fix constraint violation in ftwRich Felker1-1/+4
void* does not implicitly convert to function pointer types.
2012-09-06use restrict everywhere it's required by c99 and/or posix 2008Rich Felker2-2/+2
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
2012-08-30fix missing statics in crypt_sha256 codeRich Felker1-3/+3
2012-08-29anti-DoS rounds count limits for blowfish and des cryptRich Felker2-2/+2
all of the limits could use review, but err on the side of avoiding excessive rounds for now.
2012-08-29limit sha512 rounds to similar runtime to sha256 limitRich Felker1-1/+1
these limits could definitely use review, but for now, i feel consistency and erring on the side of preventing servers from getting bogged down by excessively-slow user-provided settings (think .htpasswd) are the best policy. blowfish should be updated to match.
2012-08-29add sha256/sha512 cryptRich Felker4-1/+700
based on versions sent to the list by nsz, with some simplification and debloating. i'd still like to get them a bit smaller, or ideally merge them into a single file with most of the code being shared, but that can be done later.
2012-08-23optimize legacy ffs functionRich Felker1-4/+2
2012-08-10add blowfish hash support to cryptRich Felker3-8/+806
there are still some discussions going on about tweaking the code, but at least thing brings us to the point of having something working in the repository. hopefully the remaining major hashes (md5,sha) will follow soon.
2012-08-09make crypt return an unmatchable hash rather than NULL on failureRich Felker1-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.
2012-08-02fix missing static in getusershell (namespace pollution)Rich Felker1-1/+1
2012-06-29replace old and ugly crypt implementationRich Felker3-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).
2012-06-20fix ptsname_r to conform to the upcoming posix requirementsRich Felker2-4/+13
it should return the error code rather than 0/-1 and setting errno.
2012-05-06add isastream (obsolete STREAMS junk)Rich Felker1-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).
2012-05-03implement stub versions of sched_*Rich Felker1-10/+0
these actually work, but for now they prohibit actually setting priority levels and report min/max priority as 0.
2012-04-24ditch the priority inheritance locks; use malloc's version of lockRich Felker1-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).
2012-04-22implement getusershell, etc. legacy functionsRich Felker1-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...
2012-04-22add getresuid and getresgid syscall wrappersRich Felker2-0/+16
2012-04-16wordexp must set the we_offs entries of we_wordv to null pointersRich Felker1-0/+4
2012-04-16fix crash in wordfree if we_offs is not initialized by the callerRich Felker1-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.
2012-03-01implement a64l and l64a (legacy xsi stuff)Rich Felker1-0/+26
2012-02-23fix (hopefully) PTRACE_TRACEME (command 0) argument handlingRich Felker1-2/+2
2012-02-17fix get_current_dir_name behaviorRich Felker1-2/+6
2012-02-17add get_current_dir_name functionRich Felker1-0/+12
2012-01-24add legacy futimes and lutimes functionsRich Felker2-0/+26
based on patch by sh4rm4. these functions are deprecated; futimens and utimensat should be used instead in new programs.
2012-01-20use prlimit syscall for getrlimit/setrlimitRich Felker2-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.
2012-01-20add prlimit syscall wrapperRich Felker1-0/+8
2012-01-18alias basename to glibc name for it, to meet abi goalsRich Felker1-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.
2011-09-16fix ptrace (maybe)Rich Felker1-1/+8
2011-09-15implement ptrace syscall wrapper (untested)Rich Felker1-0/+18
2011-09-13remove some stray trailing space charactersRich Felker1-1/+1
2011-07-30fix some bugs in setxid and update setrlimit to use __synccallRich Felker1-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.
2011-07-22check for fd exhaustion in forkptyRich Felker1-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.
2011-07-22incorrect check for open failure in openpty functionRich Felker1-1/+1
-1, not 0, indicates failure
2011-06-25wordexp cannot use we_offs unless WRDE_DOOFFS flag is setRich Felker1-1/+2
previously, a potentially-indeterminate value from we_offs was being used, resulting in wrong we_wordc and subsequent crashes in the caller.
2011-06-18fix memory leak on failure in realpathRich Felker1-4/+4
2011-05-29add useless, obsolescent function ulimitRich Felker1-0/+19
2011-04-20properly create new session/controlling terminal in forkptyRich Felker1-1/+4
2011-04-20implement (nonstandard) forkptyRich Felker1-0/+22
2011-04-19block cancellation in wordexp, handle more errorsRich Felker1-2/+17
2011-04-19avoid malloc of potentially-large string in wordexpRich Felker1-10/+28
2011-04-18protect ftw and nftw against cancellationRich Felker1-1/+6
2011-04-18protect syslog against cancellationRich Felker1-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.
2011-04-17minimal realpath implementation using /procRich Felker1-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.
2011-04-15remove stupid debug code in wordexpRich Felker1-1/+0
2011-04-15implement wordexp. first try, may be buggy. intended to be safe.Rich Felker1-0/+128
2011-04-13simplify syslog, add vsyslog interface (nonstandard)Rich Felker1-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...
2011-04-13remove useless SIGPIPE protection from syslogRich Felker1-9/+0
per the standard, SIGPIPE is not generated for SOCK_DGRAM.
2011-04-13fix syslog (corrected SIGPIPE blocking, and using dgram instead of stream)Rich Felker1-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.