summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-21 22:49:27 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-21 23:49:02 +0200
commit931f3c03d0c3af8c87a5a7fb9c56d1e1fc37522e (patch)
treeb8b0f2f3ffa9842fb84b5de8a521a2f3701c21ba /Userland/Utilities
parent90ee84621ff18faabc0684fced8f86aef63f0ab7 (diff)
downloadserenity-931f3c03d0c3af8c87a5a7fb9c56d1e1fc37522e.zip
useradd: Convert String::format() => String::formatted()
Also make more use of warnln().
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/useradd.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/Userland/Utilities/useradd.cpp b/Userland/Utilities/useradd.cpp
index 627e1209f2..bcb620c241 100644
--- a/Userland/Utilities/useradd.cpp
+++ b/Userland/Utilities/useradd.cpp
@@ -107,21 +107,22 @@ int main(int argc, char** argv)
String home;
if (!home_path)
- home = String::format("/home/%s", username);
+ home = String::formatted("/home/{}", username);
else
home = home_path;
if (create_home_dir) {
if (mkdir(home.characters(), 0700) < 0) {
- perror(String::format("failed to create directory %s", home.characters()).characters());
+ auto saved_errno = errno;
+ warnln("Failed to create directory {}: {}", home, strerror(saved_errno));
return 12;
}
if (chown(home.characters(), static_cast<uid_t>(uid), static_cast<gid_t>(gid)) < 0) {
- perror(String::format("failed to chown %s to %u:%u", home.characters(), uid, gid).characters());
+ warnln("Failed to change owner of {} to {}:{}: {}", home, uid, gid, strerror(errno));
if (rmdir(home.characters()) < 0) {
- perror(String::format("failed to rmdir %s", home.characters()).characters());
+ warnln("Failed to remove directory {}: {}", home, strerror(errno));
return 12;
}
return 12;