summaryrefslogtreecommitdiff
path: root/src/user.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-20 23:18:41 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-20 23:18:41 +0200
commit2b827a0ab06fb715290a0450a3fff56d3e6f4ee6 (patch)
treeb5e24df3fa573afd07b55a2330e88cabe2394e3f /src/user.rs
parentae4b23d95dc8792231c1e8212978be8305ee1964 (diff)
Put git repos into a user-specific dir
Diffstat (limited to 'src/user.rs')
-rw-r--r--src/user.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/user.rs b/src/user.rs
new file mode 100644
index 0000000..72aea8d
--- /dev/null
+++ b/src/user.rs
@@ -0,0 +1,7 @@
+pub fn get_username() -> Option<String> {
+ let uid = nix::unistd::getuid();
+ nix::unistd::User::from_uid(uid)
+ .ok()
+ .flatten()
+ .map(|user| user.name)
+}