File: trust.pl

package info (click to toggle)
tct 1.07-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,828 kB
  • ctags: 1,128
  • sloc: perl: 9,604; ansic: 4,861; makefile: 516; sh: 77
file content (180 lines) | stat: -rw-r--r-- 3,969 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#
#  A quick hack to suck up all the trust on a system
#
#  Currently only grabs .rhosts, & .forward files, dumps crontab and 
# at output, and xhost/xauth results... should get pipes in alias files as 
# well, other stuff.  More windowing stuff should be added.
#

require "pass.cache.pl";
require "ostype.pl";

#
# cycle through the users, grab all rhosts files
#
sub grab_user_trust_files {

print "Grabbing all trust-related files (in grab_user_trust_files())\n" if $verbose;

for $user (keys %uname2dir) {

	print "\nChecking user $user..." if $debug;

	# lots of system stuff uses same dir, only need it once...?
	# next if (defined($all_rhosts_dirs{$uname2dir{$user}}));

	for $trust_files (@user_trust_files) {

		print "looking at: $uname2dir{$user}/$trust_files\n" if $debug;
		# wildcard expansion...
		for $trust_file (<$uname2dir{$user}/$trust_files>) {

			# we want to know even about empty ones...
			print "\t($trust_file)\n" if $debug;

			next unless -e $trust_file;

			print "TF: $trust_file\n" if $debug;

			#
			# ... is a real file, not a symlink
			#
			next if -l $trust_file && !$follow_file_sym_links;

			print "something in there...\n" if $debug;

			($faux_file = $trust_file) =~ s@/@_@g;

			$resting_place="$DATA/$user_vault/$user\_$faux_file";

			#
			# can't happen, but...
			#
			if ($trust_file eq $resting_place) {
				warn "Saving $trust_file would clobber it\n";
				next;
			}
			&date_stamp($resting_place);
			# use cat instead of cp because of date stamp
			&redirect_command($CAT, $trust_file, ">>$resting_place");
			&sign_it("$resting_place");
			}
		}
	}
}

#
#  Snarf the crontab and at commands for any users that use them...
#
sub grab_user_time_trust {

print "Grabbing all time stuff (at, cron, etc) (in grab_user_time_trust())\n" if $verbose;

&date_stamp("$TRUST/time");
die "Can't open $TRUST/time (in grab_user_time_trust())\n" unless open(TT, ">>$TRUST/trust.time");

#
# if can use the by-user crontab -l command...
#
if (-x $CRONTAB) {
	my(@crontab) = ("$CRONTAB", "-l");

	# sun doesn't use the -u option, others seem to...
	if (($OS ne "SUNOS4") && ($OS ne "SUNOS5")) { push(@crontab, "-u"); }

	for $user (keys %uname2dir) {
		print "\nChecking user $user\'s $CRONTAB & $AT..." if $debug;

		&pipe_command(CRONTAB, @crontab, "$user", "-|");

		if (!$?) {
			while (<CRONTAB>) {
				print "\t$user (cron): $_" if $debug;
				print TT "$user (cron): $_";
				}
			}
		close(CRONTAB);

		#
		# &pipe_command(AT, $SU, "$user", "-c", "$AT -l", "-|");
		if (!$?) {
			while (<AT>) {
				print "\t$user (at): $_" if $debug;
				print TT "$user (at): $_";
				}
			}
		close(AT);
		}
	}
#
# for those (4.4, etc?)
#

# no error checking; if doesn't exist/can't open, don't worry about it..
open(CRONTAB, $etc_crontab);
while (<CRONTAB>) {
	print 
	print "($etc_crontab): $_" if $debug;
	print TT "($etc_crontab): $_";
	}

close(TT);

&sign_it("$TRUST/time");

}

#
# just a simple-minded couple of things
#
sub grab_window_trust {

print "Grabbing some window stuff (in grab_window_trust())\n" if $verbose;

&date_stamp("$TRUST/window_systems");
die "Can't open $TRUST/window_systems (in grab_window_trust())\n"
	unless open(WINDOWS, ">>$TRUST/window_systems");

if (-x $XHOST) {
	&pipe_command(XHOST, $XHOST, "-|");
	while (<XHOST>) {
		print "(xhost): $_" if $debug;
		print WINDOWS "(xhost): $_";
		}
	}
close(XHOST);

if (-x $XAUTH) {
	&pipe_command(XAUTH, $XAUTH, "list", "-|");
	while (<XAUTH>) {
		print "(xauth): $_" if $debug;
		print WINDOWS "(xauth): $_";
		}
	}
close(XAUTH);
close(WINDOWS);

&sign_it("$TRUST/window_systems");

}

if (!$running_under_grave_robber) {

	print "testing out all the trust functions...\n";

	require "../conf/coroner.cf";

	&determine_os();
	require "lib/dig-sig.pl";

	# Load the password stuff
	&'load_passwd_info(0,$PASSWD);
	&'load_group_info(0,$GROUP);
	$verbose = $debug = 1;

	&grab_user_trust_files();
	# &grab_user_time_trust();
	# &grab_window_trust();
	}

1;