summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2013-04-05journal: u64log2 can be expressed just as __builtin_clzll(n) ^ 63UCristian Rodríguez
2013-04-04efivars: un-leak a few stringsZbigniew Jędrzejewski-Szmek
2013-04-04util: tweak format_timespan() a bitLennart Poettering
Make sure to always print out at least one valid component instead of falling back early to 0.
2013-04-04util: add a bit of syntactic sugar to run short code fragments with a ↵Lennart Poettering
different umask
2013-04-04util: make time formatting a bit smarterLennart Poettering
Instead of outputting "5h 55s 50ms 3us" we'll now output "5h 55.050003s". Also, while outputting the accuracy is configurable. Basically we now try use "dot notation" for all time values > 1min. For >= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and finally 'us'. This should give reasonably values in most cases.
2013-04-03time: add suppot for fractional time specificationsLennart Poettering
We can now parse "0.5s" as the same as "500ms". In fact, we can parse "3.45years" correctly, too, and any other unit and fraction length.
2013-04-03fileio: don't check for errors more often than really necessaryLennart Poettering
2013-04-03fileio: write proper env var write-out codeLennart Poettering
This will properly escape all weird chars when writing env var files. With this in place we can now read and write environment files where the values contain arbitrary weird chars. This enables hostnamed and suchlike to finally properly save pretty host names with backlashes or quotes in them.
2013-04-03shared: rework env file readerLennart Poettering
Implement this with a proper state machine, so that newlines and escaped chars can appear in string assignments. This should bring the parser much closer to shell.
2013-04-03util: rename parse_usec() to parse_sec() sinds the default unit is secondsLennart Poettering
Internally we store all time values in usec_t, however parse_usec() actually was used mostly to parse values in seconds (unless explicit units were specified to define a different unit). Hence, be clear about this and name the function about what we pass into it, not what we get out of it.
2013-04-03util: rename write_one_line_file() to write_string_file()Lennart Poettering
You can write much more than just one line with this call (and we frequently do), so let's correct the naming.
2013-04-02macro: add macro for precisely determining length of decimal string ↵Lennart Poettering
formatting of a numeric type
2013-04-02util: add a bit of syntactic sugar for saving/restoring errnoLennart Poettering
2013-04-01shared/cgroup-show: fix leak of "pid"Zbigniew Jędrzejewski-Szmek
2013-04-01Always use our own MAX/MIN definitionsCristian Rodríguez
code in src/shared/macro.h only defined MAX/MIN in case they were not defined previously. however the MAX/MIN macros implemented in glibc are not of the "safe" kind but defined as: define MIN(a,b) (((a)<(b))?(a):(b)) define MAX(a,b) (((a)>(b))?(a):(b)) Avoid nasty side effects by using our own versions instead. Also fix the warnings derived from this change. [zj: - modify MAX3 macro to fix warning about _a shadowing _a, - do bootchart/svg.c too, - remove unused MIN3.]
2013-03-31Partially revert e62d8c394474Zbigniew Jędrzejewski-Szmek
The ~80 chars per line part wasn't well received.
2013-03-31ModernizationZbigniew Jędrzejewski-Szmek
Use _cleanup_ and wrap lines to ~80 chars and such.
2013-03-31strbuf: replace quick sort with bubble sortZbigniew Jędrzejewski-Szmek
No need to call the heavy artillery, when the original array is sorted. Reduces complexity from n² log n to n log n, where n is the number of items in the array, not very large, but still.
2013-03-31strbuf: fix leak on memory errorZbigniew Jędrzejewski-Szmek
Not very likely, but let's fix it for the matter of principle.
2013-03-31Remove some dead codeZbigniew Jędrzejewski-Szmek
Based on coverity report.
2013-03-31bus: parse matches locally and allow registration of callbacks for themLennart Poettering
This includes code to parse and split up match strings which will also be useful to calculate bloom filter masks when the time comes.
2013-03-30bus: implement server mode, and anonymous authenticationLennart Poettering
2013-03-30prioq: consider a NULL prioq emptyLennart Poettering
2013-03-30unit: no need to export variables if we can avoid itLennart Poettering
2013-03-29utmp: make gcc shut up, we need to pass an int here, not size_tLennart Poettering
2013-03-29Always use errno > 0 to help gccZbigniew Jędrzejewski-Szmek
gcc thinks that errno might be negative, and functions could return something positive on error (-errno). Should not matter in practice, but makes an -O4 build much quieter.
2013-03-28tests: add some silly tests for path-util.cZbigniew Jędrzejewski-Szmek
2013-03-28catalog: open up catalog internalsZbigniew Jędrzejewski-Szmek
In order to write tests for the catalog functions, they are made non-static and start taking a 'database' parameter, which is the name of a file with the preprocessed catalog entries. This makes it possible to make test-catalog part of the normal test suite, since it now only operates on files in /tmp. Some more tests are added.
2013-03-28utmp-wtmp: don't try to read past end of stringZbigniew Jędrzejewski-Szmek
systemd-199/src/shared/utmp-wtmp.c:228: buffer_size_warning: Calling strncpy with a maximum size argument of 32 bytes on destination array "store.ut_line" of size 32 bytes might leave the destination string unterminated. The destination string is unterminated on purpose, but we must remember that.
2013-03-27shared: free dt (temporary dir name) on failVáclav Pavlín
[zj: modified to not to try to rmdir() dir we haven't created.]
2013-03-26tests: skip bus test if bus cannot be openedZbigniew Jędrzejewski-Szmek
To make the result more visible, special return value is used to tell automake that the test was skipped. While at it, use the same return value in other skipped tests.
2013-03-26Simplify the meaning of %sZbigniew Jędrzejewski-Szmek
The rules governing %s where just too complicated. First of all, looking at $SHELL is dangerous. For systemd --system, it usually wouldn't be set. But it could be set if the admin first started a debug shell, let's say /sbin/sash, and then launched systemd from it. This shouldn't influence how daemons are started later on, so is better ignored. Similar reasoning holds for session mode. Some shells set $SHELL, while other set it only when it wasn't set previously (e.g. zsh). This results in fragility that is better avoided by ignoring $SHELL totally. With $SHELL out of the way, simplify things by saying that %s==/bin/sh for root, and the configured shell otherwise. get_shell() is the only caller, so it can be inlined. Fixes one issue seen with 'make check'.
2013-03-25bus: implement 'unixexec:' protocolLennart Poettering
2013-03-25bus: implement support for FD passingLennart Poettering
2013-03-23conf-parser: when we parse a string list, always fill in somethingLennart Poettering
Some code really wants to know whether there was a string list parsed, so don't take the shortcut here, and always allocate a string list, even if it is an empty one. https://bugs.freedesktop.org/show_bug.cgi?id=62558
2013-03-22dbus: Do send out "replies" to signalsColin Walters
Some parts of systemd (at least the DBus activation codepath) "reply" to signals, which of course have the no-reply flag set. We will be defensive here and still send out a reply if we're passed a signal. Regression introduced by: c6a818c82035da91e Reported-by: Mantas Mikulėnas <grawity@gmail.com> Tested-by: Mantas Mikulėnas <grawity@gmail.com>
2013-03-22util: workaround two gcc warningsZbigniew Jędrzejewski-Szmek
gcc does not know that errno cannot be negative, and warns about unitialized variables later on. Kill the warnings by returning -errno only after checking that errno is positive.
2013-03-22build-sys: move acl searching code into libsystemd-aclZbigniew Jędrzejewski-Szmek
This loop over acls is a bit too much to keep inside of another loop.
2013-03-22util: be more picky when validating hostnamesLennart Poettering
No longer allow dots at the beginning or end of host names, Or double dots. https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1152187/comments/14
2013-03-22journalctl: give a nice hint about group membership based on ACLs of ↵Lennart Poettering
/var/log/journal If we notice that we unprivileged and not in any of the groups which have access to /var/log/journal, print a nice message about which groups do. This checks and prints all groups that are in the default ACL for /var/log/journal, which is not necessarily correct for all journal files, but pretty close.
2013-03-21efivars: fix return codeZbigniew Jędrzejewski-Szmek
Was returning 1 on read error.
2013-03-21bus: implement full method call timeout logicLennart Poettering
2013-03-21shared: add simple priority queue implementationLennart Poettering
2013-03-20Remove some unused variablesZbigniew Jędrzejewski-Szmek
2013-03-20bus: implement demarshallerLennart Poettering
2013-03-20util: add hexmem() and strextend() callsLennart Poettering
2013-03-20macro: add CHAR_TO_STR macro to make a one character string from a charLennart Poettering
2013-03-20macro: don't redefine CLAMP if it is already defined by glib or some other ↵Lennart Poettering
library
2013-03-20Make PrivateTmp dirs also inaccessible from the outsideZbigniew Jędrzejewski-Szmek
Currently, PrivateTmp=yes means that the service cannot see the /tmp shared by rest of the system and is isolated from other services using PrivateTmp, but users can access and modify /tmp as seen by the service. Move the private /tmp and /var/tmp directories into a 0077-mode directory. This way unpriviledged users on the system cannot see (or modify) /tmp as seen by the service.
2013-03-18journal,shared: add _cleanup_journal_close_Zbigniew Jędrzejewski-Szmek