3 BEGIN { push(@INC, ".."); };
7 $cvs_path = &has_command($config{'cvs'});
9 $cvs_inet_name = "cvspserver";
10 $has_xinetd = &foreign_check("xinetd");
11 $has_inetd = &foreign_check("inetd");
12 $passwd_file = "$config{'cvsroot'}/CVSROOT/passwd";
13 $readers_file = "$config{'cvsroot'}/CVSROOT/readers";
14 $writers_file = "$config{'cvsroot'}/CVSROOT/writers";
15 $cvs_config_file = "$config{'cvsroot'}/CVSROOT/config";
17 @features = ('passwd', 'access', 'config', 'cvsweb');
18 %access = &get_module_acl();
19 %featureprog = ( 'passwd' => 'list_passwd.cgi',
20 'access' => 'edit_access.cgi',
21 'config' => 'edit_config.cgi',
22 'cvsweb' => 'cvsweb.cgi' );
25 # Find out if cvs is being run from inetd or xinetd
29 # Find an xinetd service on the CVS port, with the CVS command, or
31 &foreign_require("xinetd", "xinetd-lib.pl");
32 local @xic = &xinetd::get_xinetd_config();
35 next if ($x->{'name'} ne 'service');
36 local $q = $x->{'quick'};
37 if ($q->{'server'}->[0] eq $cvs_path ||
38 $q->{'server'}->[0] eq $config{'cvs'} ||
40 $x->{'value'} eq $cvs_inet_name) {
42 return { 'type' => 'xinetd',
43 'user' => $q->{'user'}->[0],
44 'command' => $q->{'server'}->[0],
45 'args' => $q->{'server'}->[0]." ".
46 $q->{'server_args'}->[0],
47 'active' => $q->{'disable'}->[0] ne 'yes',
53 # Find an inetd service on the CVS port, with the CVS command, or
55 local (%portmap, $s, $a, $i);
56 &foreign_require("inetd", "inetd-lib.pl");
57 foreach $s (&inetd::list_services()) {
58 $portmap{$s->[1]} = $s;
59 foreach $a (split(/\s+/, $s->[4])) {
63 foreach $i (&inetd::list_inets()) {
64 if ($i->[8] eq $cvs_path || $i->[8] eq $config{'cvs'} ||
65 $portmap{$i->[3]}->[2] == $cvs_port ||
66 $i->[3] eq $cvs_inet_name) {
68 return { 'type' => 'inetd',
86 open(PASSWD, $passwd_file);
90 local @p = split(/:/, $_);
92 push(@rv, { 'user' => $p[0],
96 'index' => scalar(@rv) });
106 local $lref = &read_file_lines($passwd_file);
107 push(@$lref, join(":", $_[0]->{'user'}, $_[0]->{'pass'}, $_[0]->{'unix'}));
113 local $lref = &read_file_lines($passwd_file);
114 $lref->[$_[0]->{'line'}] =
115 join(":", $_[0]->{'user'}, $_[0]->{'pass'}, $_[0]->{'unix'});
121 local $lref = &read_file_lines($passwd_file);
122 splice(@$lref, $_[0]->{'line'}, 1);
127 # Returns a list of values from the CVSROOT/config file
132 open(CONFIG, $cvs_config_file);
136 if (/^\s*([^\s=]+)\s*=\s*(.*)/) {
137 push(@rv, { 'name' => $1,
140 'index' => scalar(@rc) } );
148 # find(name, &config)
152 foreach $c (@{$_[1]}) {
153 push(@rv, $c) if (lc($c->{'name'}) eq lc($_[0]));
155 return wantarray ? @rv : $rv[0];
158 # save_cvs_config(&config, name, value, [default])
161 local $lref = &read_file_lines($cvs_config_file);
162 local $old = &find($_[1], $_[0]);
164 # Replacing an existing config line
165 $lref->[$old->{'line'}] = "$_[1]=$_[2]";
168 # Deleting a config line (unless it already exists with the default)
169 if (!$_[3] || $old->{'value'} ne $_[3]) {
170 splice(@$lref, $old->{'line'}, 1);
172 foreach $c (@{$_[0]}) {
173 $c->{'line'}-- if ($c->{'line'} > $old->{'line'});
178 # Adding a config line
179 push(@$lref, "$_[1]=$_[2]");
183 # get_cvs_version(&out)
184 # Returns the cvs command version number, or undef
187 local $out = `$config{'cvs'} -v`;
189 if ($out =~ /CVS[^0-9\.]*([0-9\.]+)/) {
197 @hist_chars = ( "F", "O", "E", "T", "C", "G", "U", "W", "A", "M", "R" );