亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? psa-chapter03.txt

?? perl語言的經典文章
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
Example code from Perl for System Administration by David N. Blank-Edelman
O'Reilly and Associates, 1st Edition, ISBN 1-56592-609-9

Chapter Three
=============
#*
#* parsing the UNIX password file "by hand"
#*

$passwd = "/etc/passwd";
open(PW,$passwd) or die "Can't open $passwd:$!\n";
while (<PW>){
    ($name,$passwd,$uid,$gid,$gcos,$dir,$shell) = split(/:/);
    # <your code here>
}
close(PW);
-------
#*
#* parsing the UNIX password file using the system libraries
#*
while(($name,$passwd,$uid,$gid,$gcos,$dir,$shell) = getpwent()){
       # <your code here>
}
endpwent();           
-------
#*
#* finding the next available UID
#*

$passwd = "/etc/passwd";
open(PW,$passwd) or die "Can't open $passwd:$!\n";
while (<PW>){
    @fields = split(/:/);
    $highestuid = ($highestuid < $fields[2]) ? $fields[2] : $highestuid;
}
close(PW);
print "The next available UID is " . ++$highestuid . "\n";
-------
#*
#* check to make sure every user owns their own home directory and
#* that the directory is not world writeable
#*

use User::pwent;
use File::stat;

# note: this code will beat heavily upon any machine using automounted homedirs
while($pwent = getpwent()){
    # make sure we stat the actual dir,even through layers of symlink
    # indirection
    $dirinfo = stat($pwent->dir."/."); 
    unless (defined $dirinfo){
        warn "Unable to stat ".$pwent->dir.": $!\n";
        next;
    }
    warn $pwent->name."'s homedir is not owned by the correct uid (".
      $dirinfo->uid." instead ".$pwent->uid.")!\n"
        if ($dirinfo->uid != $pwent->uid);

    # world writable is fine if dir is set "sticky" (i.e. 01000), 
    # see the manual page for chmod for more information
    warn $pwent->name."'s homedir is world-writable!\n"
      if ($dirinfo->mode & 022 and (!$stat->mode & 01000));
}

endpwent();
-------
#*
#* check to make sure all users have "standard" shells
#*

use User::pwent;

$shells = "/etc/shells";
open (SHELLS,$shells) or die "Unable to open $shells:$!\n";
while(<SHELLS>){
    chomp;
    $okshell{$_}++;
}
close(SHELLS);

while($pwent = getpwent()){
   warn $pwent->name." has a bad shell (".$pwent->shell.")!\n"
     unless (exists $okshell{$pwent->shell});
}
endpwent();
-------
#*
#* dump information about all local users on an NT/2000 machine
#*

use Win32::AdminMisc

# retrieve all of the local users
Win32::AdminMisc::GetUsers('','',\@users) or 
   die "Unable to get users: $!\n";

# get their attributes and print them
foreach $user (@users){
  Win32::AdminMisc::UserGetMiscAttributes('',$user,\%attribs) or 
    warn "Unable to get attrib: $!\n";
  print join(":",$user,
                 '*',
                 $attribs{USER_USER_ID},
                 $attribs{USER_PRIMARY_GROUP_ID},
                 '',
                 $attribs{USER_COMMENT},
                 $attribs{USER_FULL_NAME},
                 $attribs{USER_HOME_DIR_DRIVE}."\\".
                 $attribs{USER_HOME_DIR},
                 ''),"\n";
}
-------
#*
#* show the RID for a particular user on an NT/2000 machine
#*

use Win32::AdminMisc;

Win32::AdminMisc::UserGetMiscAttributes('',$user,\%attribs);
print $attribs{USER_USER_ID},"\n";
-------
#*
#* change the owner of a directory (and its contents) on NT/2000
#*

use Win32::Perms;
    
$acl  = new Win32::Perms();
$acl->Owner($NewAccountName);
$result = $acl->SetRecurse($dir);
$acl->Close();
-------
#*
#* retrieve the user rights for the user 'Guest' on NT/2000
#*
use Win32::Lanman;

unless(Win32::Lanman::LsaLookupNames($server, ['Guest'], \@info)
       die "Unable to lookup SID: ".Win32::Lanman::GetLastError()."\n";

unless (Win32::Lanman::LsaEnumerateAccountRights($server, 
                                                 ${$info[0]}{sid},
                                                 \@rights);
	die "Unable to query rights: ".Win32::Lanman::GetLastError()."\n"; 
-------
#*
#* add the user right that enables a user to shut down a machine to 'Guest'
#*
use Win32::Lanman;

unless (Win32::Lanman::LsaLookupNames($server, ['Guest'], \@info))
	die "Unable to lookup SID: ".Win32::Lanman::GetLastError()."\n";

unless (Win32::Lanman::LsaAddAccountRights($server, ${$info[0]}{sid}, 
					   [&SE_SHUTDOWN_NAME]))
	die "Unable to change rights: ".Win32::Lanman::GetLastError()."\n"
-------
#*
#* a subroutine that queries a user for account info and then returns
#* a data structure with this information in it (used as part of our example
#* account system)
#*
sub CollectInformation{
    # list of fields init'd here for demo purposes, this should 
    # really be kept in a central configuration file
    my @fields = qw{login fullname id type password};
    my %record;

    foreach my $field (@fields){
        print "Please enter $field: ";
        chomp($record{$field} = <STDIN>);
    }
    $record{status}="to_be_created";
    return \%record; 
}
-------
#*
#* subroutine to append account information to a queue file in XML format
#*

sub AppendAccountXML {
    # receive the full path to the file
    my $filename = shift;
    # receive a reference to an anonymous record hash  
    my $record = shift;    

    # XML::Writer uses IO::File objects for output control
    use IO::File;

    # append to that file
    $fh = new IO::File(">>$filename") or 
      die "Unable to append to file:$!\n";

    # initialize the XML::Writer module and tell it to write to 
    # filehandle $fh
    use XML::Writer;
    my $w = new XML::Writer(OUTPUT => $fh);

    # write the opening tag for each <account> record
    $w->startTag("account");

    # write all of the <account> data start/end sub-tags & contents
    foreach my $field (keys %{$record}){
	print $fh "\n\t";
	$w->startTag($field);
	$w->characters($$record{$field});
	$w->endTag;
    }
    print $fh "\n";

    # write the closing tag for each <account> record
    $w->endTag;
    $w->end;
    $fh->close();
}
-------
#*
#* parsing our queue file using XML::Parser
#*

use XML::Parser;
use Data::Dumper; # used for debugging output, not needed for XML parse
$p = new XML::Parser(ErrorContext => 3, 
		     Style        => 'Stream',
		     Pkg          => 'Account::Parse');

# handle multiple account records in a single XML queue file
open(FILE,$addqueue) or die "Unable to open $addqueue:$!\n";

# this clever read idiom courtesy of Jeff Pinyan
read(FILE, $queuecontents, -s FILE);
$p->parse("<queue>".$queuecontents."</queue>");

package Account::Parse;

sub StartTag {
    undef %record if ($_[1] eq "account");
}

sub Text {
    my $ce = $_[0]->current_element();
    $record{$ce}=$_ unless ($ce eq "account");
}

sub EndTag {
    print Data::Dumper->Dump([\%record],["account"]) 
      if ($_[1] eq "account");    
    # here's where we'd actually do something, instead of just
    # printing the record
}
-------
#*
#* writing XML using XML::Simple
#*

use XML::Simple;

# rootname sets the root element's name, we could also use xmldecl to
# add an XML declaration
print XMLout($queue, rootname =>"queue"); 
-------
#*
#* reading and printing out a queue file using XML::Simple
#*

use XML::Simple;
use Data::Dumper;  # just needed to show contents of our data structures

$queuefile = "addqueue.xml";
open(FILE,$queuefile) or die "Unable to open $queuefile:$!\n";
read (FILE, $queuecontents, -s FILE);

$queue = XMLin("<queue>".$queuecontents."</queue>");

print Data::Dumper->Dump([$queue],["queue"]);
-------
#*
#* subroutine to transform an easy to work with data structure from an 
#* XML::Simple read into a the data structure necessary to write it back
#* out again using XML::Simple (see text for more details).
#*

sub TransformForWrite{
    my $queueref = shift;
    my $toplevel = scalar each %$queueref;

    foreach my $user (keys %{$queueref->{$toplevel}}){
      my %innerhash = 
	map {$_,[$queueref->{$toplevel}{$user}{$_}] } 
	  keys %{$queueref->{$toplevel}{$user}};
      $innerhash{'login'} = [$user];
      push @outputarray, \%innerhash;
    }

    $outputref = { $toplevel => \@outputarray};
    return $outputref;
}

# sample usage
$queue = XMLin("<queue>".$queuecontents."</queue>",keyattr => ["login"]);
# <manipulate the data>
print OUTPUTFILE XMLout(TransformForWrite($queue),rootname => "queue");
-------
#*
#* wrapping an XML parse in eval to protect against bad XML code
#*
eval {$p->parse("<queue>".$queuecontents."</queue>")};
if ($@) { 
 # <do something graceful to handle the error before quitting>
};
-------
#*
#* basic UNIX account creation routine
#*

# these variables should really be set in a central configuration file
$useraddex    = "/usr/sbin/useradd";  # location of useradd executable
$passwdex     = "/bin/passwd";        # location of passwd executable
$homeUNIXdirs = "/home";              # home directory root dir
$skeldir      = "/home/skel";         # prototypical home directory
$defshell     = "/bin/zsh";           # default shell

sub CreateUNIXAccount{
    
    my ($account,$record) = @_;

    ### construct the command line, using:
    # -c = Comment field
    # -d = home dir
    # -g = group (assume same as user type)
    # -m = create home dir
    # -k = and copy in files from this skeleton dir
    # (could also use -G group, group, group to add to auxiliary groups)
    my @cmd = ($useraddex, 
	       "-c", $record->{"fullname"},
	       "-d", "$homeUNIXdirs/$account",
	       "-g", $record->{"type"},
	       "-m",
	       "-k", $skeldir,
	       "-s", $defshell,
	       $account);
    
    print STDERR "Creating account...";
    my $result = 0xff & system @cmd;
    # the return code is 0 for success, non-0 for failure, so we invert
    if ($result){
        print STDERR "failed.\n";
        return "$useraddex failed";        
    }
    else {
        print STDERR "succeeded.\n";        
    }

    print STDERR "Changing passwd...";
    unless ($result = &InitUNIXPasswd($account,$record->{"password"})){
        print STDERR "succeeded.\n";
        return "";
    }
    else {
        print STDERR "failed.\n";
        return $result;
    }
}
-------
#*
#* basic UNIX account deletion routine
#*

# these variables should really be set in a central configuration file
$userdelex = "/usr/sbin/userdel";  # location of userdel executable

sub DeleteUNIXAccount{
    my ($account,$record) = @_;

    ### construct the command line, using:
    # -r = remove the account's home directory for us
    my @cmd = ($userdelex, "-r", $account);
    
    print STDERR "Deleting account...";
    my $result = 0xffff & system @cmd;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
69av一区二区三区| 欧美日韩精品是欧美日韩精品| 久久成人免费网| 国产成人精品亚洲午夜麻豆| 91色在线porny| 99久久国产免费看| 777精品伊人久久久久大香线蕉| 亚洲精品在线电影| 亚洲综合在线观看视频| 蜜臀av一区二区在线观看| 成人ar影院免费观看视频| 欧美精品一级二级| 亚洲色图视频网| 久久99热这里只有精品| 日本久久一区二区三区| 久久久久久免费网| 亚洲国产成人porn| 麻豆成人久久精品二区三区红| 成人一二三区视频| 欧美va亚洲va| 亚洲电影欧美电影有声小说| 不卡一区二区三区四区| 337p粉嫩大胆噜噜噜噜噜91av| 亚洲午夜久久久| 91视频一区二区三区| 国产视频一区二区在线| 男人的j进女人的j一区| 国产成人在线免费观看| 91精品国产综合久久福利软件| 亚洲视频1区2区| 成人动漫精品一区二区| 久久在线观看免费| 男男视频亚洲欧美| 91麻豆精品久久久久蜜臀 | 99久久婷婷国产综合精品电影| 91久久精品一区二区三| 国产精品日韩成人| 麻豆视频观看网址久久| 制服丝袜日韩国产| 午夜久久福利影院| 欧美日韩视频一区二区| 一区二区三区高清| 欧美在线短视频| 成人欧美一区二区三区| 懂色av中文字幕一区二区三区 | 亚洲欧美中日韩| 国产剧情一区二区| 国产日韩欧美一区二区三区乱码| 激情综合色播激情啊| 欧美mv日韩mv国产| 国精产品一区一区三区mba视频| 欧美xxxx老人做受| 久久91精品久久久久久秒播| 日韩免费在线观看| 国产原创一区二区| 国产欧美日韩一区二区三区在线观看| 国模无码大尺度一区二区三区| 欧美另类高清zo欧美| 日韩在线a电影| 91精品午夜视频| 久久se精品一区二区| 久久亚洲一级片| 不卡一二三区首页| 亚洲一区二区三区在线看| 在线观看区一区二| 日韩电影一区二区三区| 日韩久久久精品| 国产精品99久久久久| 中文字幕在线观看一区二区| 91视频免费看| 午夜一区二区三区视频| 久久精品亚洲乱码伦伦中文 | 成人禁用看黄a在线| 午夜久久久久久| 国产精品九色蝌蚪自拍| 日韩一区二区影院| 91免费版pro下载短视频| 麻豆精品久久久| 亚洲综合一二区| 国产日韩欧美a| 91精品国产aⅴ一区二区| 成人av在线网| 黑人精品欧美一区二区蜜桃 | 欧美精品vⅰdeose4hd| 丁香五精品蜜臀久久久久99网站| 亚洲第一会所有码转帖| 中文字幕av不卡| 日韩精品综合一本久道在线视频| 91猫先生在线| 国产九九视频一区二区三区| 日韩不卡一二三区| 一区二区三区高清| 亚洲欧洲三级电影| 国产婷婷一区二区| 精品福利视频一区二区三区| 在线播放一区二区三区| 欧洲精品在线观看| 色久优优欧美色久优优| www.av亚洲| www.亚洲精品| a美女胸又www黄视频久久| 国产成人av自拍| 国产乱子伦一区二区三区国色天香| 日韩电影在线观看一区| 亚洲成a人片综合在线| 一区二区三区日韩欧美精品| 一色屋精品亚洲香蕉网站| 亚洲国产岛国毛片在线| 亚洲国产精品传媒在线观看| 国产日韩欧美亚洲| 国产性色一区二区| 欧美国产一区视频在线观看| 亚洲国产精品成人久久综合一区 | 成人av在线资源网| 成人网男人的天堂| av激情综合网| 91污在线观看| 91久久久免费一区二区| 欧美日韩视频在线观看一区二区三区| 欧美午夜片在线观看| 欧美日韩一区二区三区在线 | 91浏览器在线视频| 色网站国产精品| 欧美日韩美女一区二区| 欧美日韩国产高清一区二区三区| 欧美日韩一区二区欧美激情 | 欧美午夜一区二区三区免费大片| 欧美午夜片在线看| 日韩三级av在线播放| 久久久久久久久久久99999| 国产欧美一区二区精品婷婷| 国产精品久久久久三级| 亚洲精品免费视频| 日韩av不卡一区二区| 国产一区二区视频在线播放| 波多野结衣视频一区| 在线一区二区三区四区五区| 51精品秘密在线观看| 久久久精品免费免费| 国产精品久久午夜夜伦鲁鲁| 亚洲一二三区视频在线观看| 久久精品久久久精品美女| 国产精品综合av一区二区国产馆| 欧美日韩国产影片| 国产91精品入口| 一本一道波多野结衣一区二区| 欧美日韩午夜精品| 久久精品夜夜夜夜久久| 亚洲精品国产成人久久av盗摄| 日韩精品久久久久久| 国产a视频精品免费观看| 91蜜桃免费观看视频| 欧美成人高清电影在线| 国产精品国产三级国产aⅴ中文| 亚洲综合区在线| 国产一区日韩二区欧美三区| 色综合久久久久| 日韩精品在线网站| 一区二区三区在线视频观看58| 久久精品久久精品| 在线观看视频一区二区| 欧美大度的电影原声| 亚洲欧洲成人自拍| 久久er99热精品一区二区| 国产一区二区电影| 91麻豆国产香蕉久久精品| 日韩三级在线观看| 亚洲一区二区三区四区在线免费观看| 久久99精品一区二区三区三区| 91一区在线观看| 久久精品亚洲麻豆av一区二区| 五月天国产精品| 91国在线观看| 国产精品不卡在线| 国产美女在线观看一区| 欧美一区二区三区四区在线观看 | 日本一区二区成人| 免费人成在线不卡| 欧美精品一级二级三级| 亚洲精品视频免费看| 国产高清久久久久| wwwwxxxxx欧美| 乱一区二区av| 欧美一区二区久久| 婷婷综合另类小说色区| 欧美羞羞免费网站| 亚洲精品成人少妇| 色94色欧美sute亚洲13| 国产精品成人网| 不卡的av电影在线观看| 国产亚洲短视频| 福利一区二区在线| 中文字幕第一区二区| 国产成人一级电影| 久久亚洲一区二区三区明星换脸| 欧美bbbbb| 久久综合久色欧美综合狠狠| 久久国产精品99久久久久久老狼 | 欧美午夜一区二区三区免费大片| 亚洲欧美一区二区三区久本道91|