[opencoe-cvs] coekernel/src/UserMgmt/src/UserMgmt/bin COE_add_app_reserved_data,NONE,1.1 COE_delete_
Status: Alpha
Brought to you by:
rbroberg
From: <rbr...@us...> - 2003-11-25 06:29:25
|
Update of /cvsroot/opencoe/coekernel/src/UserMgmt/src/UserMgmt/bin In directory sc8-pr-cvs1:/tmp/cvs-serv5330/src/UserMgmt/src/UserMgmt/bin Added Files: COE_add_app_reserved_data COE_delete_app_reserved_data COE_get_app_reserved_data Log Message: [ 845321 ] Extend COE to handle optional Application data --- NEW FILE: COE_add_app_reserved_data --- #!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w #- # Copyright (C) 2002, Federal Linux Systems # License: GNU Lesser General Public License, v2.1 #- use strict; use Coe; my $PRGM="COE_add_app_reserved_data"; my $VERSION="@VERSION@"; if (@ARGV == 0) { &useage; exit 202; } sub useage { print "Useage: $PRGM [options] \"<AppName>\" <Scope> "; print "-f<N> \"<Value>\" [-f<N> \"<Value>\"]*\n"; } my $arg1; my $newstr=""; my $app=""; my $ascope="a"; my $i; my @appdat; my @fieldval=("","","","","","","","","","",""); my @oldval=("","","","","","","","","","",""); my @newval; while (@ARGV > 0 ){ $arg1=cleanString(shift,1); if ("$arg1" eq "-h") { &useage; exit 0; } elsif ("$arg1" eq "-H") { coeMan("COE_COMP/UserMgmt/docs/man/$PRGM"); exit 0; } elsif ("$arg1" eq "-V") { print "VERSION: $VERSION\n"; exit 0; } else { $app=$arg1; $ascope=cleanString(shift,1); while (@ARGV > 0) { # the argument is formatted "-f<N> Value" # so I am parsing the first arg for N # and using that to define array postion N+3 with Value # I should only allow for reserved num 1-6 # The +5 normalizes the string positions 7-12 # where 0 is first string field $arg1=cleanString(shift,3); $_=$arg1; s/-f//; $i=$_; $fieldval[$i+5]=cleanString(shift,1); } } } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # do simple sanity checks # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # is this a legal scope ? if ( "$ascope" eq "l" || "$ascope" eq "local") { $ascope="local"; } elsif ("$ascope" eq "g" || "$ascope" eq "global") { $ascope="global"; } else { &useage; exit 202; } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # define some stuff # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # path for the App data file my $coedat=coeFileConv "COE_USER/$ascope/Profiles/.AppData.dat"; # App.dat format => appname:appnorm:acctgrp:exec:args:icon # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # cat out the App.dat file, removing the app string for alteration # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| $i=0; #open file, "$APPDAT" || die "Cannot open file $APPDAT: $!\n"; my $COEDAT = readFile ($coedat); while (<$COEDAT>) { chomp(); if (/^$app:/) { @oldval=split(':'); } else { $appdat[$i++]=$_; } } close $COEDAT; # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # exit if no such app is found with COE_NO_SUCH_APP # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| if ("$oldval[0]" eq "") { exit 205; } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # construct a new app string to replace the old one # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # if a new value is defined, use it, else default to the old value #$newval[0]=$oldval[0]; #$newval[1]=$oldval[1]; #$newval[2]=$oldval[2]; #$newval[3]=$oldval[3]; #$newval[4]=$oldval[4]; #$newval[5]=$oldval[5]; #$newval[6]=$oldval[6]; #$newval[7]=$oldval[7]; #$newval[8]=$oldval[8]; #$newval[9]=$oldval[9]; @newval=@oldval; $i=5; while ($i < 12) { if ("$fieldval[$i]" ne "") { $newval[$i]=$fieldval[$i]; } else { $newval[$i]=$oldval[$i]; } $i++; } # build the new user string $i=1; $newstr=$newval[0]; while ($i < 10) { $newstr=$newstr.":".$newval[$i++]; } chomp($newstr); # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # rewrite the file with the old data and the new user string # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| #open file, (">$APPDAT") || die "Cannot open file $APPDAT: $!\n"; open COEDAT, (">$coedat") || die "Cannot open file $coedat: $!\n"; foreach (@appdat) { print COEDAT "$_\n"; } print COEDAT "$newstr\n"; close COEDAT; exit 0; --- NEW FILE: COE_delete_app_reserved_data --- #!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w #- # Copyright (C) 2002, Federal Linux Systems # License: GNU Lesser General Public License, v2.1 #- use strict; use Coe; my $PRGM="COE_delete_app_reserved_data"; my $VERSION="@VERSION@"; if (@ARGV == 0) { &useage; exit 202; } sub useage { print "Useage: $PRGM [options] {App} {Scope} {-f<N>} {-f<N>} ...\n"; } my $arg1; my $newstr; my $newval; my $oldval; my $app="0"; my $ascope="a"; my $coedat; my $COEDAT; my $i; my @newval; my @profdat; my @oldval; my @fieldval = ("z", "z", "z", "z", "z", "z", "z", "z", "z", "z"); while (@ARGV > 0 ){ $arg1=cleanString(shift,1); if ("$arg1" eq "-h") { &useage; exit; } elsif ("$arg1" eq "-H") { coeMan("COE_COMP/UserMgmt/docs/man/$PRGM"); exit 0; } elsif ("$arg1" eq "-V") { print "VERSION: $VERSION\n"; exit 0; } else { $app=$arg1; $ascope=cleanString(shift,1); $i=0; while (@ARGV > 0) { # the argument is formatted "-f<N>" # so I am parsing the first arg for N # and using that to define array postion N+3 with aflag # I should only allow for reserved num 1-6 # The +5 normalizes the string positions 6-13 # where 0 is first string field # zremq is just a nonsense string used as a flag $arg1=cleanString(shift,1); $_=$arg1; s/-f//; $i=$_; $fieldval[$i+5]=cleanString("zremq", 1); } } } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # do simple sanity checks # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # is this a legal scope ? if ( "$ascope" eq "l" || "$ascope" eq "local" ) { $ascope="local"; } elsif ("$ascope" eq "g" || "$ascope" eq "global") { $ascope="global"; } else { &useage; } # does this acct group exist? # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # define some stuff # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # path for the App data COEDAT $coedat=coeFileConv "COE_USER/$ascope/Profiles/.AppData.dat"; # App.dat format:: appname:appnorm:acctgrp:exec:args:icon # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # cat out the App.dat COEDAT, removing the user string for alteration # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| $i=0; $COEDAT=readFile ($coedat); while (<$COEDAT>) { if (/^$app:/) { chomp(); @oldval=split(':'); } else { $profdat[$i++]=cleanString($_,3); } } close $COEDAT; #- does this app exist if ( $#oldval < 0 ) { exit 205; } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # construct a new user string to replace the old one nulling defined fields # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # build the new user string $newstr=$oldval[0]; $newstr=$newstr.":".$oldval[1]; $newstr=$newstr.":".$oldval[2]; $newstr=$newstr.":".$oldval[3]; $i=5; while ($i < 12) { if ("$fieldval[$i]" eq "zremq") { $newstr=$newstr.":"; } else { $newstr=$newstr.":".$oldval[$i]; } $i++; } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # rewrite the COEDAT with the old data and the new user string # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| open COEDAT, (">$coedat") || die "Cannot open COEDAT $coedat: $!\n"; foreach (@profdat) { print COEDAT "$_\n"; } print COEDAT "$newstr\n"; close COEDAT; --- NEW FILE: COE_get_app_reserved_data --- #!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w #- # Copyright (C) 2002, Federal Linux Systems # License: GNU Lesser General Public License, v2.1 #- use strict; use Coe; my $PRGM="COE_get_app_reserved_data"; my $VERSION="@VERSION@"; if (@ARGV == 0) { &useage; exit 202; } sub useage { print "Useage: $PRGM [options] {App} {Scope} {-f<N>} {-f<N>} ...\n"; } my $arg1; my $newstr; my $newval; my $oldval; my $app="0"; my $ascope="a"; my $coedat; my $COEDAT; my $cnt=0; my $i; my @newval; my @profdat; my @oldval; my @fieldval = ("z", "z", "z", "z", "z", "z", "z", "z", "z", "z"); while (@ARGV > 0 ){ $arg1=cleanString(shift,1); if ("$arg1" eq "-h") { &useage; exit; } elsif ("$arg1" eq "-H") { coeMan("COE_COMP/UserMgmt/docs/man/$PRGM"); exit 0; } elsif ("$arg1" eq "-V") { print "VERSION: $VERSION\n"; exit 0; } else { $app=$arg1; $ascope=cleanString(shift,1); $i=0; while (@ARGV > 0) { # the argument is formatted "-f<N>" # so I am parsing the first arg for N # and using that to define array postion N+3 with aflag # I should only allow for reserved num 1-6 # The +5 normalizes the string positions 6-13 # where 0 is first string field # zremq is just a nonsense string used as a flag $arg1=cleanString(shift,1); $_=$arg1; s/-f//; $i=$_; $fieldval[$cnt++]=$i-1; } } } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # do simple sanity checks # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # is this a legal scope ? if ( "$ascope" eq "l" || "$ascope" eq "local" ) { $ascope="local"; } elsif ("$ascope" eq "g" || "$ascope" eq "global") { $ascope="global"; } else { &useage; } # does this acct group exist? # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # define some stuff # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # path for the App data COEDAT $coedat=coeFileConv "COE_USER/$ascope/Profiles/.AppData.dat"; # App.dat format:: appname:appnorm:acctgrp:exec:args:icon # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # cat out the App.dat COEDAT, removing the user string for alteration # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| $i=0; $COEDAT=readFile ($coedat); while (<$COEDAT>) { if (/^$app:/) { chomp(); @oldval=split(':'); } else { $profdat[$i++]=cleanString($_,3); } } close $COEDAT; #- does this app exist if ( $#oldval < 0 ) { exit 205; } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # construct a new user string to replace the old one nulling defined fields # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # build the new user string $newstr=$oldval[$fieldval[0]]; for ($i=1; $i<$cnt; $i++) { if ("$oldval[$fieldval[$i]]" ne "") { $newstr=$newstr.":".$oldval[$fieldval[$i]]; } else { $newstr=$newstr.":"; } } # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # print the discoverd fields # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| print "$newstr\n"; |