This file is indexed.

/usr/share/arc/se.pl is in nordugrid-arc-aris 4.0.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#!/usr/bin/perl
use Getopt::Long;
use lib "$ENV{PWD}/";
use File::Basename;
use Cwd;

BEGIN {
    # Make sure we write utf8
    eval {binmode(STDOUT, ":utf8")};
    # Used for reading UTF8 encoded grid-mapfile
    eval {require Encode; import Encode "decode"};
    my $oldcwd = getcwd();

    my $basedir = dirname($0);
    chdir $basedir or die "$basedir: $!";
    $basedir = getcwd();

    my $pkgdatadir = $basedir;

    chdir $oldcwd or die "$oldcwd: $!";

    unshift @INC, $pkgdatadir;
}

use LogUtils ( 'start_logging', 'error', 'warning', 'debug' );
use Shared;
use ConfigParser;

#
# populates the nordugrid-se LDAP entry
#


GetOptions("dn:s" => \$config{dn},	
     	   "se:s" => \$config{se}, 
	   "config:s" => \$config{conf_file},
	   "valid-to:i" => \$config{ttl},
	   "loglevel:i" => \$config{loglevel},
	   "help|h" => \$print_help   
	  ); 

my $USAGE=<<EOUSAGE
script usage:
       mandatory arguments: --dn         
                            --config    
                            --se

       optional arguments:  --valid-to   
                            --loglevel   

       this help:           --help
EOUSAGE
;

if ($print_help) { 
    print "$USAGE\n";
		exit;
}

if (($config{dn} and $config{conf_file} and $config{se}) eq "") {
    error("a command line argument is missing, see --help ");
    die "a command line argument is missing, see --help "
};


#
#  default values
#
$config{ttl} 		||= 600;
$config{port} 		= "2811";
$config{gridmap} 	= "/etc/grid-security/grid-mapfile";
$config{"x509_user_cert"} = "/etc/grid-security/hostcert.pem";
$config{"x509_cert_dir"} = "/etc/grid-security/certificates/";
$config{ng_location}	||= $ENV{ARC_LOCATION} ||= "/usr";
my $globus_location	||= $ENV{GLOBUS_LOCATION} ||= "/usr";
chomp ($config{hostname} = `/bin/hostname -f`);

my $parser = ConfigParser->new($config{conf_file}) or die "Cannot parse config file at '$config{conf_file}'\n";

# copy blocks that are relevant to %config

%config = ( %config, $parser->get_section('common') );
%config = ( %config, $parser->get_section('infosys') );
%config = ( %config, $parser->get_section('gridftpd') );
%config = ( %config, $parser->get_section("se/$config{se}") );
if ($config{assigned_storage}) {
    %config = ( %config, $parser->get_section("gridftpd/$config{assigned_storage}") );
    %config = ( %config, $parser->get_section("httpsd/$config{assigned_storage}") );
}

if (! defined ($config{name})) {
   $config{name} = $config{se};
}


#foreach $variable (keys %config) {
#   print "$variable: $config{$variable}\n";
#}
#exit;
   
#
# read the mappings from the grid-mapfile to a %users hash
#

unless (open mapfile, "<$config{gridmap}") {
 error("can't open gridmapfile $config{gridmap}");
 die "can't open gridmapfile $config{gridmap}";
}

while($line = <mapfile>) {
    chomp($line);  

    if ( $line =~ m/\"([^"]+)\"\s+(\S+)/) {
	my $subject = $1;
	eval {
	    $subject = decode("utf8", $subject, 1);
	};
	$users{$subject} = $2;
    }
}				    
close mapfile;	


# The DN of the entry
print "dn: $config{dn}\n";

# The objectclasses
print "objectclass: Mds\n";
print "objectclass: nordugrid-se\n";

# The attributes
print "nordugrid-se-name: $config{name}:$config{hostname}\n";


#nordugrid-se-url
if ( $config{type} =~/sse/i ) {
    # TODO: figure out which port(s) to use   
    my $sse_url = "sse://$config{hostname}".$config{path};
    print "nordugrid-se-url: $sse_url\n";
}
else {
    print "nordugrid-se-url: gsiftp://$config{hostname}:$config{port}","$config{path}\n";
}


$config{alias} and print "nordugrid-se-aliasname: $config{alias}\n";
$config{type} and print "nordugrid-se-type: $config{type}\n";
$config{comment} and print "nordugrid-se-comment: $config{comment}\n";

#nordugrid-se-accesscontrol
if ($config{plugin} =~/gacl/i) {
    print "nordugrid-se-accesscontrol: gacl\n";
}
elsif ($config{plugin} =~/file/i) {
    print "nordugrid-se-accesscontrol: trivial\n";
}
elsif ( $config{type} =~/sse/i ) {
    print "nordugrid-se-accesscontrol: gacl\n";
}
else {
    print "nordugrid-se-accesscontrol: other\n";
}

#nordugrid-se-acl
my @se_acl = split /\[separator\]/, $config{authorizedvo};
foreach my $listentry (@se_acl) {
   print "nordugrid-se-acl: VO:$listentry\n";
}

#nordugrid-se-totalspace/freespace
my $diskfree;
my $disktotal;
my $diskarea;
if ( $config{type} =~/sse/i ) {
    $diskarea = $config{storage};
}
else {
    $diskarea = $config{mount};
}

if ( -d $diskarea) {
  # check if on afs  
  if ($diskarea =~ /\/afs\//) {
	$diskfree =`fs listquota $diskarea 2>/dev/null`;   
	if ($diskfree) {
	  $diskfree =~ /\n\S+\s+(\d+)\s+(\d+)\s+\d+%\s+\d+%/;
	  $diskfree = int (($1 - $2)/1024);
	  $disktotal= int $1/1024;
	} 
	else {
	  $diskfree = 0;
	  $disktotal = 0;
	}  
  } 
  # "ordinary" disk 
  else {
	$dfstring =`df -k -P $diskarea 2>/dev/null`;   
	if ($dfstring) {
	  $dfstring =~ /\n\S+\s+(\d+)\s+\d+\s+(\d+)\s+\d+/;
	  $diskfree = int $2/1024;
	  $disktotal = int $1/1024;
	}
	else {
	  $diskfree = 0;
	  $disktotal = 0;
	}
  }
}
else { 
  $diskfree = 0;
  $disktotal = 0;
  warning("SE mount directory $diskarea is not found");
}
print "nordugrid-se-totalspace: $disktotal\n";
print "nordugrid-se-freespace: $diskfree\n";

#nordugrid-se-middleware

#NorduGrid toolkit
$ENV{LD_LIBRARY_PATH}.=":" if $ENV{LD_LIBRARY_PATH};
$ENV{LD_LIBRARY_PATH}.="$config{ng_location}/lib:$globus_location/lib";

print "nordugrid-se-middleware: nordugrid-4.0.0\n";

#Globus Toolkit version 									          
#globuslocation/share/doc/VERSION								          
if (-r "$globus_location/share/doc/VERSION" ) { 						          
   chomp ( $globusversion =  `cat $globus_location/share/doc/VERSION 2>/dev/null`);	 	          
   if ($?) {								          
      warning("error in reading the globus version file")	     		          
   }												          
}												          
#globuslocation/bin/globus-version 								          
elsif (-x "$globus_location/bin/globus-version" ) {						          
   chomp ( $globusversion =  `$globus_location/bin/globus-version 2>/dev/null`);        	          
   if ($?) {								          
      warning("error in executing the $globus_location/bin/globus-version command")    
   }												          
}												          
if ($globusversion) {										          
   print "nordugrid-se-middleware: globus-$globusversion\n";
}												          

#nordugrid-se-issuerca
my $hostcert = $config{"x509_user_cert"};    
# find an openssl
my $openssl_command = '';
for my $path (split ':', "$ENV{PATH}:$globus_location/bin") {
    $openssl_command = "$path/openssl" and last if -x "$path/openssl";
}
error("Could not find openssl command") unless $openssl_command;
my $issuerca=`$openssl_command x509 -noout -issuer -in $hostcert 2>/dev/null`;
if ( $? ) {
   warning("error in executing $openssl_command x509 -noout -issuer -in $hostcert")
}
if ( $issuerca =~ s/issuer= // ) {
   chomp($issuerca);
   print "nordugrid-se-issuerca: $issuerca\n";
}

# List certs and elliminate duplication in case 2 soft links point to the same file.
opendir(CERTDIR, $config{x509_cert_dir}) || error("failed listing certificates directory $config{x509_cert_dir}: $!");
my %certfiles;
for (readdir CERTDIR) {
    next unless m/\.\d$/;
    my $file = $config{x509_cert_dir}."/".$_;
    my $link = -l $file ? readlink $file : $_;
    $certfiles{$link} = $file;
}
closedir CERTDIR;
my $issuerca_hash;
foreach my $cert ( sort values %certfiles ) {
   my $ca_sn = `$openssl_command x509 -checkend 60 -noout -subject -in $cert`;
   $ca_sn =~ s/subject= //;
   chomp($ca_sn);
   if ( $ca_sn eq $issuerca) {
      $issuerca_hash = `$openssl_command x509 -noout -hash -in $cert`;
      chomp ($issuerca_hash);
   }
   if ($?) {
     $config{loglevel} and warning("CA $ca_sn is expired");
     next;
   }
   $trustedca{$ca_sn} = 1;
}

#nordugrid-se-issuerca-hash
if ( $issuerca_hash ) {
   chomp ($issuerca_hash);
   print "nordugrid-se-issuerca-hash: $issuerca_hash\n";
}

#nordugrid-se-trustedca	
foreach my $listentry (sort keys %trustedca) {	
   print "nordugrid-se-trustedca: $listentry\n";
}		

#nordugrid-se-authuser
foreach $listentry (keys %users) {
   print "nordugrid-se-authuser: $listentry\n";
}

#Mds-validfrom/to
my ( $valid_from, $valid_to ) = Shared::mds_valid($config{ttl});

print "Mds-validfrom: $valid_from\n";
print "Mds-validto: $valid_to\n";


my $runtime =  time - $^T;
debug("execution time: $runtime");
if ($runtime >= 4 ) {  
   warning("SLOW script: $runtime");  
}

exit;