summaryrefslogtreecommitdiff
path: root/scripts/vyatta-sudo
blob: bb95ae52dd0928335fdfc9cae568a480ef10f8c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/perl
#

# Look if user is in sudo group
use strict;
use warnings;

sub isadmin {
    my $gid = getgrnam("sudo");
    return unless $gid;

    # is $gid in list of current groups
    return grep { $_ eq $gid } split / /, $(;
}

die "Missing command arguement\n" unless @ARGV;

exec ('sudo', @ARGV ) if (isadmin());

print "This account is not authorized to run this command\n";
exit 1;