summaryrefslogtreecommitdiff
path: root/src/core/execute.c
AgeCommit message (Collapse)Author
2013-04-18move _cleanup_ attribute in front of the typeHarald Hoyer
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18core/execute: only clean the environment, if we have oneHarald Hoyer
2013-04-18execute: always add in EXECUTABLE= field when we log something about executionLennart Poettering
2013-04-17core/execute: report invalid environment variables from filesHarald Hoyer
Because "export key=val" is not supported by systemd, an error is logged where the invalid assignment is coming from. Introduce strv_env_clean_log() to log invalid environment assignments, where logging is possible and allowed. parse_env_file_internal() is modified to allow WHITESPACE in keys, to report the issues later on.
2013-04-17core/execute.c: debug log final execve() with argv[]Harald Hoyer
https://bugzilla.redhat.com/show_bug.cgi?id=772073
2013-04-08cgroup: clean-upsLennart Poettering
2013-04-08cgroup: always keep access mode of 'tasks' and 'cgroup.procs' files in ↵Lennart Poettering
cgroup directories in sync
2013-04-05Add _cleanup_globfree_Zbigniew Jędrzejewski-Szmek
Fixes a memleak in error path in exec_context_load_environment.
2013-04-05Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek
Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
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 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-03-31ModernizationZbigniew Jędrzejewski-Szmek
Use _cleanup_ and wrap lines to ~80 chars and such.
2013-03-31execute: convert secure bits into mask properlyZbigniew Jędrzejewski-Szmek
C.f. http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5975c725dfd6f7d36f493ab1453fbdbd35c1f0e3
2013-03-27core: check return value of rm_rf_dangerous and warn if it failsVáclav Pavlín
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-15core: reuse the same /tmp, /var/tmp and inaccessible dirMichal Sekletar
All Execs within the service, will get mounted the same /tmp and /var/tmp directories, if service is configured with PrivateTmp=yes. Temporary directories are cleaned up by service itself in addition to systemd-tmpfiles. Directory which is mounted as inaccessible is created at runtime in /run/systemd.
2013-02-28core/execute: determine if ExecContext may fiddle with /dev/consoleMichal Schmidt
There is some guesswork, but it should work satisfactorily for the purpose of knowing when to suppress printing of status messages.
2013-02-28core/execute: add internal is_terminal_output()Michal Schmidt
Similar to already existing is_terminal_input(). Note that the only current user (connect_logger_as) is never called for EXEC_OUTPUT_TTY, so it won't mind whether we accept it.
2013-02-16execute: increase severity of journal connect failure messageMichal Schmidt
journald is supposed to work. Failure to connect to its socket implies losing messages. It should be a very unusual event. Log the failure with LOG_CRIT. Just because this unit's stdout/stderr failed to connect to the journal does not necessarily mean that we shouldn't try to log the failure using a structured entry, so let's use log_struct_unit.
2013-02-16execute: unify setup_{output,error}Michal Schmidt
The functions are quite similar. Unify them into one. The source gets shorter, the binary gets slightly smaller.
2013-02-16execute: robustness against journald failuresMichal Schmidt
Almost every unit logs to the journal. If journald gets a permanent failure, units would not be able to start (exit code 209/STDOUT). Add a fallback to /dev/null to avoid making the system entirely unusable in such a case.
2013-02-14honor SELinux labels, when creating and writing config filesHarald Hoyer
Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2013-02-11env: considerably beef up environment cleaning logicLennart Poettering
Now, actually check if the environment variable names and values used are valid, before accepting them. With this in place are at some places more rigid than POSIX, and less rigid at others. For example, this code allows lower-case environment variables (which POSIX suggests not to use), but it will not allow non-UTF8 variable values. All in all this should be a good middle ground of what to allow and what not to allow as environment variables. (This also splits out all environment related calls into env-util.[ch])
2013-01-19execute: Fix seccomp support on x32Jonathan Callen
In the x32 ABI, syscall numbers start at 0x40000000. Mask that bit on x32 for lookups in the syscall_names array and syscall_filter and ensure that syscall.h is parsed correctly. [zj: added SYSCALL_TO_INDEX, INDEX_TO_SYSCALL macros.]
2013-01-18core: log USER_UNIT instead of UNIT if in user sessionMirco Tischler
2013-01-09tabs to spacesThomas Hindoe Paaboel Andersen
Skipped bootchart and various files that looked like they should be kept in sync with external sources.
2013-01-04Added globbing support to EnvironmentFilePekka Lundstrom
This patch allows globbing to be used with EnvironmentFile option. Example: EnvironmentFile=/etc/foo.d/*.conf t. Pekka
2012-12-05core: add catalog entry and MESSAGE_ID for overmountingZbigniew Jędrzejewski-Szmek
2012-10-30shared, core: do not always accept numbers in string lookupsMichal Schmidt
The behaviour of the common name##_from_string conversion is surprising. It accepts not only the strings from name##_table but also any number that falls within the range of the table. The order of items in most of our tables is an internal affair. It should not be visible to the user. I know of a case where the surprising numeric conversion leads to a crash. We will allow the direct numeric conversion only for the tables where the mapping of strings to numeric values has an external meaning. This holds for the following lookup tables: - netlink_family, ioprio_class, ip_tos, sched_policy - their numeric values are stable as they are defined by the Linux kernel interface. - log_level, log_facility_unshifted - the well-known syslog interface. We allow the user to use numeric values whose string names systemd does not know. For instance, the user may want to test a new kernel featuring a scheduling policy that did not exist when his systemd version was released. A slightly unpleasant effect of this is that the name##_to_string conversion cannot return pointers to constant strings anymore. The strings have to be allocated on demand and freed by the caller.
2012-10-18systemd: use structured logging for unit changesZbigniew Jędrzejewski-Szmek
Information which unit a log entry pertains to enables systemctl status to display more log messages.
2012-10-18core/execute: use cleanup_strv_freeZbigniew Jędrzejewski-Szmek
2012-09-18execute: apply PAM logic only to main process if PermissionsStartOnly is setLennart Poettering
https://bugs.freedesktop.org/show_bug.cgi?id=54176
2012-08-13namespace: rework namespace supportLennart Poettering
- don't use pivot_root() anymore, just reuse root hierarchy - first create all mounts, then mark them read-only so that we get the right behaviour when people want writable mounts inside of read-only mounts - don't pass invalid combinations of MS_ constants to the kernel
2012-07-20unit: split off KillContext from ExecContext containing only kill definitionsLennart Poettering
2012-07-17execute: free syscall filter array after useLennart Poettering
2012-07-17execute: support syscall filtering using seccomp filtersLennart Poettering
2012-07-16unit: introduce %s specifier for the user shellLennart Poettering
2012-06-26core: make systemd.confirm_spawn=1 actually workLennart Poettering
This adds a timeout if the TTY cannot be acquired and makes sure we always output the question to the console, never to the TTY of the respective service.
2012-06-22journal: set the _SYSTEMD_UNIT field for messages from terminated processesEelco Dolstra
As described in https://bugs.freedesktop.org/show_bug.cgi?id=50184 the journal currently doesn't set fields such as _SYSTEMD_UNIT properly for messages coming from processes that have already terminated. This means among other things that "systemctl status" may not show some of the output of services that wrote messages just before they exited. This patch fixes this by having processes that log to the journal write their unit identifier to journald when the connection to /run/systemd/journal/stdout is opened. Journald stores the unit ID and uses it to fill in _SYSTEMD_UNIT when it cannot be obtained normally (i.e. from the cgroup). To prevent impersonating another unit, this information is only used when the caller is root. This doesn't fix the general problem of getting metadata about messages from terminated processes (which requires some kernel support), but it allows "systemctl status" and similar queries to do the Right Thing for units that log via stdout/stderr.
2012-06-04silence gcc warning on 32 bitKay Sievers
2012-06-04remove support for deprecated /proc/self/oom_adjKay Sievers
2012-05-31util: introduce a proper nsec_t and make use of it where appropriateLennart Poettering
2012-05-24main: add configuration option to alter capability bounding set for PID 1Lennart Poettering
This also ensures that caps dropped from the bounding set are also dropped from the inheritable set, to be extra-secure. Usually that should change very little though as the inheritable set is empty for all our uses anyway.
2012-05-24service: for Type=idle units consider START_PRE, START, START_POST all as ACTIVELennart Poettering
We want to avoid a deadlock when a service has ExecStartPre= programs that wait for the job queue to run empty because of Type=idle, but which themselves keep the queue non-empty because START_PRE was considered ACTIVATING and hence the job not complete. With this patch we alter the state translation table so that it is impossible ever to wait for Type=idle unit, hence removing the deadlock.
2012-05-22execute: use a much lower idle timeout that default timeLennart Poettering
The idle timeout after all is for cosmetics only, hence avoid any substantial delays just for it.
2012-05-21sd-pam: Drop uid so parent signal arrives at child.Auke Kok
The PAM helper thread needs to capture the death signal from the parent, but is prohibited from doing so since when the child dies as normal user, the kernel won't allow it to send a TERM to the PAM helper thread which is running as root. This causes the PAM threads to never exit, accumulating after user sessions exit. There is however really no need to keep the PAM threads running as root, so, we can just setresuid() to the same user as defined in the unit file for the parent thread (User=). This makes the TERM signal arrive as normal. In case setresuid() fails, we ignore the error, so we at least fall back to the current behaviour.
2012-05-08util: split-out path-util.[ch]Kay Sievers
2012-04-24service: introduce Type=idle and use it for gettysLennart Poettering
Type=idle is much like Type=simple, however between the fork() and the exec() in the child we wait until PID 1 informs us that no jobs are left. This is mostly a cosmetic fix to make gettys appear only after all boot output is finished and complete. Note that this does not impact the normal job logic as we do not delay the completion of any jobs. We just delay the invocation of the actual binary, and only for services that otherwise would be of Type=simple.
2012-04-13service: place control command in subcgroup control/Lennart Poettering
Previously, we were brutally and onconditionally killing all processes in a service's cgroup before starting the service anew, in order to ensure that StartPre lines cannot be misused to spawn long-running processes. On logind-less systems this has the effect that restarting sshd necessarily calls all active ssh sessions, which is usually not desirable. With this patch control processes for a service are placed in a sub-cgroup called "control/". When starting a service anew we simply kill this cgroup, but not the main cgroup, in order to avoid killing any long-running non-control processes from previous runs. https://bugzilla.redhat.com/show_bug.cgi?id=805942
2012-04-12execute: when we can't get the requested rlimit, get the next closestLennart Poettering