summaryrefslogtreecommitdiff
path: root/src/firstboot/firstboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firstboot/firstboot.c')
-rw-r--r--src/firstboot/firstboot.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index a765d6d219..cda96d484a 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -32,8 +32,11 @@
#include "mkdir.h"
#include "time-util.h"
#include "path-util.h"
+#include "random-util.h"
#include "locale-util.h"
#include "ask-password-api.h"
+#include "terminal-util.h"
+#include "hostname-util.h"
static char *arg_root = NULL;
static char *arg_locale = NULL; /* $LANG */
@@ -50,8 +53,6 @@ static bool arg_copy_locale = false;
static bool arg_copy_timezone = false;
static bool arg_copy_root_password = false;
-#define prefix_roota(p) (arg_root ? (const char*) strjoina(arg_root, p) : (const char*) p)
-
static void clear_string(char *x) {
if (!x)
@@ -85,13 +86,13 @@ static void print_welcome(void) {
if (done)
return;
- os_release = prefix_roota("/etc/os-release");
+ os_release = prefix_roota(arg_root, "/etc/os-release");
r = parse_env_file(os_release, NEWLINE,
"PRETTY_NAME", &pretty_name,
NULL);
if (r == -ENOENT) {
- os_release = prefix_roota("/usr/lib/os-release");
+ os_release = prefix_roota(arg_root, "/usr/lib/os-release");
r = parse_env_file(os_release, NEWLINE,
"PRETTY_NAME", &pretty_name,
NULL);
@@ -249,7 +250,7 @@ static int process_locale(void) {
unsigned i = 0;
int r;
- etc_localeconf = prefix_roota("/etc/locale.conf");
+ etc_localeconf = prefix_roota(arg_root, "/etc/locale.conf");
if (faccessat(AT_FDCWD, etc_localeconf, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
return 0;
@@ -323,7 +324,7 @@ static int process_timezone(void) {
const char *etc_localtime, *e;
int r;
- etc_localtime = prefix_roota("/etc/localtime");
+ etc_localtime = prefix_roota(arg_root, "/etc/localtime");
if (faccessat(AT_FDCWD, etc_localtime, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
return 0;
@@ -402,7 +403,7 @@ static int process_hostname(void) {
const char *etc_hostname;
int r;
- etc_hostname = prefix_roota("/etc/hostname");
+ etc_hostname = prefix_roota(arg_root, "/etc/hostname");
if (faccessat(AT_FDCWD, etc_hostname, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
return 0;
@@ -427,7 +428,7 @@ static int process_machine_id(void) {
char id[SD_ID128_STRING_MAX];
int r;
- etc_machine_id = prefix_roota("/etc/machine-id");
+ etc_machine_id = prefix_roota(arg_root, "/etc/machine-id");
if (faccessat(AT_FDCWD, etc_machine_id, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
return 0;
@@ -453,7 +454,7 @@ static int prompt_root_password(void) {
if (!arg_prompt_root_password)
return 0;
- etc_shadow = prefix_roota("/etc/shadow");
+ etc_shadow = prefix_roota(arg_root, "/etc/shadow");
if (faccessat(AT_FDCWD, etc_shadow, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
return 0;
@@ -525,9 +526,9 @@ static int process_root_password(void) {
struct spwd item = {
.sp_namp = (char*) "root",
- .sp_min = 0,
- .sp_max = 99999,
- .sp_warn = 7,
+ .sp_min = -1,
+ .sp_max = -1,
+ .sp_warn = -1,
.sp_inact = -1,
.sp_expire = -1,
.sp_flag = (unsigned long) -1, /* this appears to be what everybody does ... */
@@ -542,7 +543,7 @@ static int process_root_password(void) {
const char *etc_shadow;
int r;
- etc_shadow = prefix_roota("/etc/shadow");
+ etc_shadow = prefix_roota(arg_root, "/etc/shadow");
if (faccessat(AT_FDCWD, etc_shadow, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
return 0;