Commit graph

17 commits

Author SHA1 Message Date
Liav A
1d0066a5cc Userland/pls: Use Core::System::exec_command method to execute a command 2022-11-05 18:00:58 -06:00
Lucas CHOLLET
e1edd620ee pls: Use LibCore::Account::login() instead of manually setting the uid
In addition to changing the uid, the method also changes the gid and
properly sets groups. So this patch will also mitigate the security
issue of `pls`.
2022-09-28 00:35:36 +01:00
sin-ack
e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
Tim Schumacher
93488d6d5a pls: Implement support for --preserve-env 2022-06-28 19:09:23 +01:00
Tim Schumacher
38677f63c6 pls: Don't rely on getenv to find TERM
This allows us to skip storing the actual backing data in a separate
`Vector`, as we know that we are working with `environ`-backed storage
here.

Also, while the logic is currently very similar to what `getenv` does
internally, this allows us to eventually implement custom environment
variable filters while remaining linear in run time.
2022-06-28 19:09:23 +01:00
Sam Atkins
d2b32924d6 pls: Use Core::System::exec() 2022-04-11 21:09:42 +02:00
Idan Horowitz
11599a3342 pls: Stop on first non option when parsing arguments
This allows using pls on a program with arguments more ergonomically,
e.g. `pls -- echo "hello friends"` can now simply be done as:
`pls echo "hello friends"`.
2021-12-28 22:03:33 +02:00
Andreas Kling
9e9662b695 pls: Port to LibMain :^) 2021-12-16 22:48:17 +01:00
Brian Gianforcaro
df04283d61 LibCore: Make Account::authenticate take a SecretString
To encourage users to use the SecretString API, change the API so that
Account::authenticate only accepts a SecretString.
2021-09-12 16:36:52 +02:00
Brian Gianforcaro
9e667453c7 LibCore: Make get_password return SecretString instead of String
We shouldn't let secrets sit around in memory, as they could potentially
be retrieved by an attacker, or left in memory during a core dump.
2021-09-12 16:36:52 +02:00
pyunbiwi
68d07320cf Userland: Add as-user execution to the pls utility
Commands may be executed as a specific user by passing the user's UID to
the '-u' flag in pls.
2021-08-16 21:16:30 +02:00
Andreas Kling
597539aa4c pls: Fix typo in TERM environment variable propagation 2021-05-30 23:13:52 +02:00
Andreas Kling
33f2eeea4a pls: Drastically simplify this program
Since this program is setuid-root, it should be as simple as possible.

To that end, remove `/etc/plsusers` and use filesystem permissions to
achieve the same thing. `/bin/pls` is now only executable by `root` or
members of the `wheel` group.

Also remove all the logic that went to great lengths to `unveil()` a
minimal set of filesystem paths that may be used for the command.
The complexity-to-benefit ratio did not seem justified, and I think
we're better off keeping this simple.

Finally, remove pledge promises the moment they are no longer needed.
2021-05-30 23:09:37 +02:00
Brendan Coles
340cecaf80 pls: Unveil search paths with browse permissions 2021-05-30 10:41:25 +01:00
Jesse Buhagiar
d44e2c9ad9 Userland: Check sudoers file perms and owner in pls
As per comment found in #6319 by @bcoles, `pls` should check the
permissions and owner of the sudoers file to ensure that it hasn't
been compromised.
2021-05-29 22:33:12 +04:30
Jesse Buhagiar
82b48d867d Userland: Implement pls, a sudo clone 2021-05-29 22:33:12 +04:30