Private
Server IP : 195.201.23.43  /  Your IP : 3.17.156.160
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/webmin/at/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/at/at-lib.pl
# at-lib.pl
# Functions for listing and creating at jobs

use strict;
use warnings "once";
no warnings "redefine";
our (%text, %config); 
our $remote_user;

BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
our %access = &get_module_acl();

do "$config{'at_style'}-lib.pl";

# wrap_lines(text, width)
# Given a multi-line string, return an array of lines wrapped to
# the given width
sub wrap_lines
{
my @rv;
my $w = $_[1];
foreach my $rest (split(/\n/, $_[0])) {
	if ($rest =~ /\S/) {
		while(length($rest) > $w) {
			push(@rv, substr($rest, 0, $w));
			$rest = substr($rest, $w);
			}
		push(@rv, $rest);
		}
	else {
		# Empty line .. keep as it is
		push(@rv, $rest);
		}
	}
return @rv;
}

# can_edit_user(&access, user)
sub can_edit_user
{
my %umap;
map { $umap{$_}++; } split(/\s+/, $_[0]->{'users'});
if ($_[0]->{'mode'} == 1 && !$umap{$_[1]} ||
    $_[0]->{'mode'} == 2 && $umap{$_[1]}) { return 0; }
elsif ($_[0]->{'mode'} == 3) {
	return $remote_user eq $_[1];
	}
else {
	return 1;
	}
}

# list_allowed()
# Returns a list of all users in the cron allow file
sub list_allowed
{
local $_;
my @rv;
no strict "subs";
&open_readfile(ALLOW, $config{allow_file});
while(<ALLOW>) {
	next if (/^\s*#/);
	chop; push(@rv, $_) if (/\S/);
	}
close(ALLOW);
use strict "subs";
return @rv;
}


# list_denied()
# Return a list of users from the cron deny file
sub list_denied
{
local $_;
my @rv;
no strict "subs";
&open_readfile(DENY, $config{deny_file});
while(<DENY>) {
	next if (/^\s*#/);
	chop; push(@rv, $_) if (/\S/);
	}
close(DENY);
use strict "subs";
return @rv;
}


# save_allowed(user, user, ...)
# Save the list of allowed users
sub save_allowed
{
&lock_file($config{allow_file});
if (@_) {
	local($_);
	no strict "subs";
	&open_tempfile(ALLOW, ">$config{allow_file}");
	foreach my $u (@_) {
		&print_tempfile(ALLOW, $u,"\n");
		}
	&close_tempfile(ALLOW);
	use strict "subs";
	chmod(0444, $config{allow_file});
	}
else {
	&unlink_file($config{allow_file});
	}
&unlock_file($config{allow_file});
}


# save_denied(user, user, ...)
# Save the list of denied users
sub save_denied
{
&lock_file($config{deny_file});
if (@_ || !-r $config{'allow_file'}) {
	no strict "subs";
	&open_tempfile(DENY, ">$config{deny_file}");
	foreach my $u (@_) {
		&print_tempfile(DENY, $u,"\n");
		}
	&close_tempfile(DENY);
	use strict "subs";
	chmod(0444, $config{deny_file});
	}
else {
	&unlink_file($config{deny_file});
	}
&unlock_file($config{deny_file});
}

# can_use_at(user)
# Returns 1 if some user is allowed to use At jobs, based on the allow
# any deny files.
sub can_use_at
{
my ($user) = @_;
my (@allow, @deny, @denied);
if (!$config{'allow_file'}) {
	return 1;	# not supported by OS
	}
elsif (@allow = &list_allowed()) {
	return &indexof($user, @allow) >= 0;	# check allowed list
	}
elsif (@deny = &list_denied()) {
	return &indexof($user, @denied) < 0;	# check denied list
	}
else {
	return 1;	# if neither exists, fall back to allowing all
	}
}

1;

Private