sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

50-patina-first-user.rules (1433B)


      1 // The greeter may administer accounts, which is what makes the first one, only while no human account
      2 // can log in: none exists (uid 1000 up, with a shell), or the ones that do are all still locked. That
      3 // is what keeps the window open for the password and for taking the account back out if that fails,
      4 // and closes it the moment a password is set. ADR-0012's alternative to a helper of our own.
      5 //
      6 // Any doubt closes it: if a check fails, the account counts as able to log in.
      7 polkit.addRule(function(action, subject) {
      8     if (subject.user !== "greetd") return;
      9     if (action.id !== "org.freedesktop.accounts.user-administration") return;
     10     try {
     11         var humans = polkit.spawn(["/usr/bin/getent", "passwd"]).split("\n")
     12             .map(function(line) { return line.split(":"); })
     13             .filter(function(f) {
     14                 var uid = parseInt(f[2], 10);
     15                 return uid >= 1000 && uid < 60000 && !/(nologin|false)$/.test(f[6] || "");
     16             });
     17         var canLogIn = humans.filter(function(f) {
     18             var locked = polkit.spawn(["/usr/bin/busctl", "--system", "get-property",
     19                 "org.freedesktop.Accounts", "/org/freedesktop/Accounts/User" + f[2],
     20                 "org.freedesktop.Accounts.User", "Locked"]);
     21             return locked.indexOf("true") === -1;
     22         });
     23         if (canLogIn.length === 0) return polkit.Result.YES;
     24     } catch (e) {
     25         return;
     26     }
     27 });