Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7056eb31

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 7056eb314ec1b4686239a4001564e7b0eb081183
  • Vorgänger 1a36c8fc
  • Nachfolger 88e5a86e

Gruppe und Benutzer beim Starten des Task-Servers ändern, sofern gewünscht

Conflicts:

config/emmvee.conf.default

Unterschiede anzeigen:

config/task_server.conf.default
3 3
login =
4 4
# Set to 1 for debug messages in /tmp/lx-office-debug.log
5 5
debug = 0
6
# Chose a system user the daemon should run under when started as root.
7
run_as = www
scripts/task_server.pl
14 14
use Data::Dumper;
15 15
use DateTime;
16 16
use English qw(-no_match_vars);
17
use POSIX qw(setuid setgid);
17 18
use SL::Auth;
18 19
use SL::DB::BackgroundJob;
19 20
use SL::BackgroundJob::ALL;
......
58 59
  die "cannot find locale for user $login" unless $::locale   = Locale->new('de');
59 60
}
60 61

  
62
sub drop_privileges {
63
  my $user = $::emmvee_conf{task_server}->{run_as};
64
  return unless $user;
65

  
66
  my ($uid, $gid);
67
  while (my @details = getpwent()) {
68
    next unless $details[0] eq $user;
69
    ($uid, $gid) = @details[2, 3];
70
    last;
71
  }
72
  endpwent();
73

  
74
  if (!$uid) {
75
    print "Error: Cannot drop privileges to ${user}: user does not exist\n";
76
    exit 1;
77
  }
78

  
79
  if (!setgid($gid)) {
80
    print "Error: Cannot drop group privileges to ${user} (group ID $gid): $!\n";
81
    exit 1;
82
  }
83

  
84
  if (!setuid($uid)) {
85
    print "Error: Cannot drop user privileges to ${user} (user ID $uid): $!\n";
86
    exit 1;
87
  }
88
}
89

  
61 90
sub gd_preconfig {
62 91
  my $self = shift;
63 92

  
......
66 95
  die "Missing section [task_server] in config file"                unless $config{task_server};
67 96
  die "Missing key 'login' in section [task_server] in config file" unless $config{task_server}->{login};
68 97

  
98
  drop_privileges();
69 99
  lxinit();
70 100

  
71 101
  return ();

Auch abrufbar als: Unified diff