+static char *specifier_user_name(char specifier, void *data, void *userdata) {
+ Service *s = userdata;
+ int r;
+ const char *username;
+
+ /* get USER env from our own env if set */
+ if (!s->exec_context.user)
+ return getusername_malloc();
+
+ /* fish username from passwd */
+ username = s->exec_context.user;
+ r = get_user_creds(&username, NULL, NULL, NULL, NULL);
+ if (r < 0)
+ return NULL;
+
+ return strdup(username);
+}
+
+static char *specifier_user_home(char specifier, void *data, void *userdata) {
+ Service *s = userdata;
+ int r;
+ const char *username, *home;
+
+ /* return HOME if set, otherwise from passwd */
+ if (!s->exec_context.user) {
+ char *h;
+
+ r = get_home_dir(&h);
+ if (r < 0)
+ return NULL;
+
+ return h;
+ }
+
+ username = s->exec_context.user;
+ r = get_user_creds(&username, NULL, NULL, &home, NULL);
+ if (r < 0)
+ return NULL;
+
+ return strdup(home);
+}
+
+static char *specifier_user_shell(char specifier, void *data, void *userdata) {
+ Service *s = userdata;
+ int r;
+ const char *username, *shell;
+
+ /* return HOME if set, otherwise from passwd */
+ if (!s->exec_context.user) {
+ char *sh;
+
+ r = get_shell(&sh);
+ if (r < 0)
+ return strdup("/bin/sh");
+
+ return sh;
+ }
+
+ username = s->exec_context.user;
+ r = get_user_creds(&username, NULL, NULL, NULL, &shell);
+ if (r < 0)
+ return strdup("/bin/sh");
+
+ return strdup(shell);
+}
+