diff options
| author | Frediano Ziglio <fziglio@redhat.com> | 2016-07-12 14:09:23 +0100 |
|---|---|---|
| committer | Frediano Ziglio <fziglio@redhat.com> | 2016-07-12 14:09:23 +0100 |
| commit | daa89c92f6506dbeb5ac48e5dde8b11e5e258bfd (patch) | |
| tree | 361cb33dc4ab6f640e2683476ff1317742d3cff5 /latency.c | |
| parent | d887177216e0c4e2ae4cf9b5fca0f1aab57c8144 (diff) | |
Allows execution with suid bit
Allow to call the executable from normal user.
The reset of the environment is for security reasons.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'latency.c')
| -rw-r--r-- | latency.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -83,8 +83,20 @@ static const unit rate_units[] = { int main(int argc, char **argv) { + uid_t ruid = getuid(), euid = geteuid(); + if (ruid != euid && euid == 0) { + clearenv(); + setenv("HOME", "/root", 1); + setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin", 1); + setenv("SHELL", "/bin/sh", 1); + setuid(0); + } + tun_fd = tun_setup(); + if (ruid != euid) + setuid(ruid); + if (argc < 3) usage(); |
