mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 06:25:37 +03:00
Merge pull request #21252 from poettering/homed-record-dir-env-var
homed: add env var to override dir where we fine stored user records
This commit is contained in:
commit
874cbf675d
@ -401,3 +401,35 @@ and `homectl`:
|
|||||||
current and a future password are required, for example if the password is to
|
current and a future password are required, for example if the password is to
|
||||||
be changed. In that case `$PASSWORD` shall carry the current (i.e. old)
|
be changed. In that case `$PASSWORD` shall carry the current (i.e. old)
|
||||||
password and `$NEWPASSWORD` the new.
|
password and `$NEWPASSWORD` the new.
|
||||||
|
|
||||||
|
`systemd-homed`:
|
||||||
|
|
||||||
|
* `$SYSTEMD_HOME_ROOT` – defines an absolute path where to look for home
|
||||||
|
directories/images. When unspecified defaults to `/home/`. This is useful for
|
||||||
|
debugging purposes in order to run a secondary `systemd-homed` instance that
|
||||||
|
operates on a different directory where home directories/images are placed.
|
||||||
|
|
||||||
|
* `$SYSTEMD_HOME_RECORD_DIR` – defines an absolute path where to look for
|
||||||
|
fixated home records kept on the host. When unspecified defaults to
|
||||||
|
`/var/lib/systemd/home/`. Similar to `$SYSTEMD_HOME_ROOT` this is useful for
|
||||||
|
debugging purposes, in order to run a secondary `systemd-homed` instance that
|
||||||
|
operates on a record database entirely separate from the host's.
|
||||||
|
|
||||||
|
* `$SYSTEMD_HOME_DEBUG_SUFFIX` – takes a short string that is suffixed to
|
||||||
|
`systemd-homed`'s D-Bus and Varlink service names/sockets. This is also
|
||||||
|
understood by `homectl`. This too is useful for running an additiona copy of
|
||||||
|
`systemd-homed` that doesn't interfere with the host's main one.
|
||||||
|
|
||||||
|
* `$SYSTEMD_HOMEWORK_PATH` – configures the path to the `systemd-homework`
|
||||||
|
binary to invoke. If not specified defaults to
|
||||||
|
`/usr/lib/systemd/systemd-homework`.
|
||||||
|
|
||||||
|
Combining these four environment variables is pretty useful when
|
||||||
|
debugging/developing `systemd-homed`:
|
||||||
|
```sh
|
||||||
|
SYSTEMD_HOME_DEBUG_SUFFIX=foo \
|
||||||
|
SYSTEMD_HOMEWORK_PATH=/home/lennart/projects/systemd/build/systemd-homework \
|
||||||
|
SYSTEMD_HOME_ROOT=/home.foo/ \
|
||||||
|
SYSTEMD_HOME_RECORD_DIR=/var/lib/systemd/home.foo/ \
|
||||||
|
/home/lennart/projects/systemd/build/systemd-homed
|
||||||
|
```
|
||||||
|
@ -133,3 +133,7 @@ int bus_message_append_secret(sd_bus_message *m, UserRecord *secret) {
|
|||||||
|
|
||||||
return sd_bus_message_append(m, "s", formatted);
|
return sd_bus_message_append(m, "s", formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *home_record_dir(void) {
|
||||||
|
return secure_getenv("SYSTEMD_HOME_RECORD_DIR") ?: "/var/lib/systemd/home/";
|
||||||
|
}
|
||||||
|
@ -25,3 +25,5 @@ int bus_message_append_secret(sd_bus_message *m, UserRecord *secret);
|
|||||||
/* Many of our operations might be slow due to crypto, fsck, recursive chown() and so on. For these
|
/* Many of our operations might be slow due to crypto, fsck, recursive chown() and so on. For these
|
||||||
* operations permit a *very* long timeout */
|
* operations permit a *very* long timeout */
|
||||||
#define HOME_SLOW_BUS_CALL_TIMEOUT_USEC (2*USEC_PER_MINUTE)
|
#define HOME_SLOW_BUS_CALL_TIMEOUT_USEC (2*USEC_PER_MINUTE)
|
||||||
|
|
||||||
|
const char *home_record_dir(void);
|
||||||
|
@ -300,9 +300,9 @@ int home_save_record(Home *h) {
|
|||||||
return r;
|
return r;
|
||||||
|
|
||||||
(void) mkdir("/var/lib/systemd/", 0755);
|
(void) mkdir("/var/lib/systemd/", 0755);
|
||||||
(void) mkdir("/var/lib/systemd/home/", 0700);
|
(void) mkdir(home_record_dir(), 0700);
|
||||||
|
|
||||||
fn = strjoina("/var/lib/systemd/home/", h->user_name, ".identity");
|
fn = strjoina(home_record_dir(), "/", h->user_name, ".identity");
|
||||||
|
|
||||||
r = write_string_file(fn, text, WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_MODE_0600|WRITE_STRING_FILE_SYNC);
|
r = write_string_file(fn, text, WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_MODE_0600|WRITE_STRING_FILE_SYNC);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -316,7 +316,7 @@ int home_unlink_record(Home *h) {
|
|||||||
|
|
||||||
assert(h);
|
assert(h);
|
||||||
|
|
||||||
fn = strjoina("/var/lib/systemd/home/", h->user_name, ".identity");
|
fn = strjoina(home_record_dir(), "/", h->user_name, ".identity");
|
||||||
if (unlink(fn) < 0 && errno != ENOENT)
|
if (unlink(fn) < 0 && errno != ENOENT)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ unlink_this_file:
|
|||||||
if (unlinkat(dir_fd, fname, 0) < 0)
|
if (unlinkat(dir_fd, fname, 0) < 0)
|
||||||
return log_error_errno(errno, "Failed to remove empty user record file %s: %m", fname);
|
return log_error_errno(errno, "Failed to remove empty user record file %s: %m", fname);
|
||||||
|
|
||||||
log_notice("Discovered empty user record file /var/lib/systemd/home/%s, removed automatically.", fname);
|
log_notice("Discovered empty user record file %s/%s, removed automatically.", home_record_dir(), fname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,10 +446,10 @@ static int manager_enumerate_records(Manager *m) {
|
|||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
|
|
||||||
d = opendir("/var/lib/systemd/home/");
|
d = opendir(home_record_dir());
|
||||||
if (!d)
|
if (!d)
|
||||||
return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno,
|
return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno,
|
||||||
"Failed to open /var/lib/systemd/home/: %m");
|
"Failed to open %s: %m", home_record_dir());
|
||||||
|
|
||||||
FOREACH_DIRENT(de, d, return log_error_errno(errno, "Failed to read record directory: %m")) {
|
FOREACH_DIRENT(de, d, return log_error_errno(errno, "Failed to read record directory: %m")) {
|
||||||
_cleanup_free_ char *n = NULL;
|
_cleanup_free_ char *n = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user