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

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

?? psa-chapter03.txt

?? perl語言的經典文章
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
    # the return code is 0 for success, non-0 for failure, so we invert
    if (!$result){
        print STDERR "succeeded.\n";
        return "";
    }
    else {
        print STDERR "failed.\n";
	     return "$userdelex failed";
    }
}
-------
#*
#* routine to change a UNIX password 
#*
use Expect;

sub InitUNIXPasswd {
    my ($account,$passwd) = @_;

    # return a process object
    my $pobj = Expect->spawn($passwdex, $account);
    die "Unable to spawn $passwdex:$!\n" unless (defined $pobj);

    # do not log to stdout (i.e. be silent)
    $pobj->log_stdout(0);

    # wait for password & password re-enter prompts, 
    # answering appropriately
    $pobj->expect(10,"New password: ");
    # Linux sometimes prompts before it is ready for input, so we pause
    sleep 1;
    print $pobj "$passwd\r";
    $pobj->expect(10, "Re-enter new password: ");
    print $pobj "$passwd\r";

    # did it work?
    $result = (defined ($pobj->expect(10, "successfully changed")) ? 
  	                                  "" : "password change failed");

    # close the process object, waiting up to 15 secs for 
    # the process to exit
    $pobj->soft_close();
    
    return $result;
}
-------
#*
#* basic local user account creation routine for NT/2000
#*
use Win32::Lanman;   # for account creation
use Win32::Perms;    # to set the permissions on the home directory

$homeNTdirs = "\\\\homeserver\\home";         # home directory root dir


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

    # create this account on the local machine 
    # (i.e. empty first parameter)
    $result = Win32::Lanman::NetUserAdd("", 
			               {'name'      => $account,
					'password'  => $record->{password},
					'home_dir'  => "$homeNTdirs\\$account",
					'full_name' => $record->{fullname}});
    return Win32::Lanman::GetLastError() unless ($result);

    # add to appropriate LOCAL group (first get the SID of the account)
    # we assume the group name is the same as the account type
    die "SID lookup error: ".Win32::Lanman::GetLastError()."\n" unless
      (Win32::Lanman::LsaLookupNames("", [$account], \@info));
    $result = Win32::Lanman::NetLocalGroupAddMember("",$record->{type}, 
						       ${$info[0]}{sid});
    return Win32::Lanman::GetLastError() unless ($result);

    # create home directory
    mkdir "$homeNTdirs\\$account",0777 or
      return "Unable to make homedir:$!";

    # now set the ACL and owner of the directory
    $acl = new Win32::Perms("$homeNTdirs\\$account");
    $acl->Owner($account);

    # we give the user full control of the directory and all of the 
    # files that will be created within it (hence the two separate calls)
    $acl->Allow($account, FULL, DIRECTORY|CONTAINER_INHERIT_ACE);
    $acl->Allow($account, FULL, 
                          FILE|OBJECT_INHERIT_ACE|INHERIT_ONLY_ACE);
    $result = $acl->Set();
    $acl->Close();

    return($result ? "" : $result);
}
-------
#*
#* basic account deletion routine for NT/2000
#*

use Win32::Lanman;   # for account deletion
use File::Path;      # for recursive directory deletion

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

    # remove user from LOCAL groups only. If we wanted to also 
    # remove from global groups we could remove the word "Local" from 
    # the two Win32::Lanman::NetUser* calls *e.g. NetUserGetGroups)
    die "SID lookup error: ".Win32::Lanman::GetLastError()."\n" unless
      (Win32::Lanman::LsaLookupNames("", [$account], \@info));
    Win32::Lanman::NetUserGetLocalGroups($server, $account,'', \@groups);
    foreach $group (@groups){
        print "Removing user from local group ".$group->{name}."...";
        print(Win32::Lanman::NetLocalGroupDelMember("", 
						    $group->{name},
						    ${$info[0]}{sid}) ?     
                                                  "succeeded\n" : "FAILED\n");
    }

    # delete this account on the local machine 
    # (i.e. empty first parameter)
    $result = Win32::Lanman::NetUserDel("", $account);

    return Win32::Lanman::GetLastError() if ($result);

    # delete the home directory and its contents
    $result = rmtree("$homeNTdirs\\$account",0,1);
	
    # rmtree returns the number of items deleted, 
    # so if we deleted more than 0,it is likely that we succeeded 
    return $result;
}
-------
#*
#* initialization subroutine for our basic account system
#*

sub InitAccount{

    use XML::Writer;

    $record   = { fields => [login,fullname,id,type,password]};
    $addqueue   = "addqueue";  # name of add account queue file
    $delqueue   = "delqueue";  # name of del account queue file
    $maindata   = "accountdb"; # name of main account database file

    if ($^O eq "MSWin32"){
        require Win32::Lanman;
        require Win32::Perms;
        require File::Path;

        # location of account files
        $accountdir = "\\\\server\\accountsystem\\";
        # mail lists, example follows 
        $maillists  = "$accountdir\\maillists\\";    
        # home directory root
        $homeNTdirs = "\\\\homeserver\\home";
        # name of account add subroutine
        $accountadd = "CreateNTAccount";
        # name of account del subroutine             
        $accountdel = "DeleteNTAccount";             
    }
    else {
        require Expect;
        # location of account files
        $accountdir   = "/usr/accountsystem/";
        # mail lists, example follows   
        $maillists    = "$accountdir/maillists/";
        # location of useradd executable
        $useraddex    = "/usr/sbin/useradd";
        # location of userdel executable
        $userdelex    = "/usr/sbin/userdel";     
        # location of passwd executable
        $passwdex     = "/bin/passwd";
        # home directory root dir
        $homeUNIXdirs = "/home";
        # prototypical home directory
        $skeldir      = "/home/skel";            
        # default shell
        $defshell     = "/bin/zsh";
        # name of account add subroutine
        $accountadd = "CreateUNIXAccount";
        # name of account del subroutine
        $accountdel = "DeleteUNIXAccount";       
    }   
}
-------
#*
#* program to process the account queue
#*

# this is just all of the subroutines from above placed into a file called
# "Account.pm" in our module load path (e.g. in the current directory)
use Account; 
use XML::Simple;

&InitAccount;     # read in our low level routines
&ReadAddQueue;    # read and parse the add account queue
&ProcessAddQueue; # attempt to create all accounts in the queue
&DisposeAddQueue; # write account record either to main database or back
                  # to queue if there is a problem

# read in the add account queue to the $queue data structure
sub ReadAddQueue{
    open(ADD,$accountdir.$addqueue) or 
      die "Unable to open ".$accountdir.$addqueue.":$!\n";
    read (ADD, $queuecontents, -s ADD);
    close(ADD);
    $queue = XMLin("<queue>".$queuecontents."</queue>",
                   keyattr => ["login"]);
}

# iterate through the queue structure, attempting to create an account
# for each request (i.e. each key) in the structure
sub ProcessAddQueue{
    foreach my $login (keys %{$queue->{account}}){
        $result = &$accountadd($login,$queue->{account}->{$login});
        if (!$result){
            $queue->{account}->{$login}{status} = "created";
        }
        else {
            $queue->{account}->{$login}{status} = "error:$result";
        }
    }
}

# now iterate through the queue structure again. For each account with 
# a status of "created", append to main database. All others get written
# back to the add queue file, overwriting it.
sub DisposeAddQueue{
    foreach my $login (keys %{$queue->{account}}){
        if ($queue->{account}->{$login}{status} eq "created"){
            $queue->{account}->{$login}{login} = $login;
            $queue->{account}->{$login}{creation_date} = time;
            &AppendAccountXML($accountdir.$maindata,
                              $queue->{account}->{$login});
            delete $queue->{account}->{$login};
            next;
        }
    }

    # all we have left in $queue at this point are the accounts that 
    # could not be created

    # overwrite the queue file
    open(ADD,">".$accountdir.$addqueue) or 
      die "Unable to open ".$accountdir.$addqueue.":$!\n";
    # if there are accounts which could not be created write them
    if (scalar keys %{$queue->{account}}){ 
        print ADD XMLout(&TransformForWrite($queue),rootname => undef);
    } 
    close(ADD);
}	    
-------
#*
#* program to process the delete queue
#*

use Account;      # see description above
use XML::Simple;

&InitAccount;     # read in our low level routines
&ReadDelQueue;    # read and parse the add account queue
&ProcessDelQueue; # attempt to delete all accounts in the queue
&DisposeDelQueue; # write account record either to main database or back
                  # to queue if there is a problem

# read in the del user queue to the $queue data structure
sub ReadDelQueue{
    open(DEL,$accountdir.$delqueue) or 
      die "Unable to open ".$accountdir.$delqueue.":$!\n";
    read (DEL, $queuecontents, -s DEL);
    close(DEL);
    $queue = XMLin("<queue>".$queuecontents."</queue>",
                   keyattr => ["login"]);
}

# iterate through the queue structure, attempting to delete an account for
# each request (i.e. each key) in the structure
sub ProcessDelQueue{
    foreach my $login (keys %{$queue->{account}}){
        $result = &$accountdel($login,$queue->{account}->{$login});
        if (!$result){
            $queue->{account}->{$login}{status} = "deleted";
        }
        else {
            $queue->{account}->{$login}{status} = "error:$result";
        }
    }
}

# read in the main database and then iterate through the queue
# structure again. For each account with a status of "deleted", change
# the main database information. Then write the main database out again.
# All which could not be deleted are written back to the del queue
# file, overwriting it.
sub DisposeDelQueue{
    &ReadMainDatabase;

    foreach my $login (keys %{$queue->{account}}){
        if ($queue->{account}->{$login}{status} eq "deleted"){
            unless (exists $maindb->{account}->{$login}){
                warn "Could not find $login in $maindata\n";
                next;
            }
            $maindb->{account}->{$login}{status} = "deleted";
            $maindb->{account}->{$login}{deletion_date} = time;
            delete $queue->{account}->{$login};
            next;
       }
    }

    &WriteMainDatabase;

    # all we have left in $queue at this point are the accounts that
    # could not be deleted
    open(DEL,">".$accountdir.$delqueue) or 
      die "Unable to open ".$accountdir.$addqueue.":$!\n";
    # if there are accounts which could not be created, else truncate
    if (scalar keys %{$queue->{account}}){ 
        print DEL XMLout(&TransformForWrite($queue),rootname => undef);
    } 
    close(DEL);
}	    

sub ReadMainDatabase{
    open(MAIN,$accountdir.$maindata) or 
      die "Unable to open ".$accountdir.$maindata.":$!\n";
    read (MAIN, $dbcontents, -s MAIN);
    close(MAIN);
    $maindb = XMLin("<maindb>".$dbcontents."</maindb>",
                    keyattr => ["login"]);
}

sub WriteMainDatabase{
    # note: it would be *much, much safer* to write to a temp file 
    # first and then swap it in if the data was written successfully
    open(MAIN,">".$accountdir.$maindata) or 
      die "Unable to open ".$accountdir.$maindata.":$!\n";
    print MAIN XMLout(&TransformForWrite($maindb),rootname => undef);
    close(MAIN);
}
-------
#*
#* generate mailing list include files from the main account databae
#*
use Account;         # just to get the file locations
use XML::Simple;

&InitAccount;
&ReadMainDatabase;
&WriteFiles;

# read the main database into a hash of lists of hashes
sub ReadMainDatabase{
    open(MAIN,$accountdir.$maindata) or 
      die "Unable to open ".$accountdir.$maindata.":$!\n";
    read (MAIN, $dbcontents, -s MAIN);
    close(MAIN);
    $maindb = XMLin("<maindb>".$dbcontents."</maindb>",keyattr => [""]);
}

# iterate through the lists, compile the list of accounts of a certain 
# type and store them in a hash of lists. Then write out the contents of 
# each key to a different file.
sub WriteFiles {
    foreach my $account (@{$maindb->{account}}){
        next if $account->{status} eq "deleted";
        push(@{$types{$account->{type}}},$account->{login});
    }
    
    foreach $type (keys %types){
        open(OUT,">".$maillists.$type) or 
          die "Unable to write to ".$accountdir.$maillists.$type.":$!\n";
        print OUT join("\n",sort @{$types{$type}})."\n";
        close(OUT);
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区精品欧美日韩一区二区三区 | 国产一区二区三区av电影 | 久久99久久精品| 天天色天天爱天天射综合| 一区二区三区不卡视频| 亚洲精品乱码久久久久| 91精品国产欧美一区二区18| 色综合天天综合给合国产| wwwwww.欧美系列| 在线观看不卡视频| 不卡的av网站| 91麻豆国产福利精品| 波多野结衣亚洲| 成人久久18免费网站麻豆| 风流少妇一区二区| av成人老司机| 欧美影院精品一区| 欧美精品一卡二卡| 欧美成人精品1314www| 精品av久久707| 中文字幕精品一区二区三区精品| 国产精品国产三级国产有无不卡 | 国产精品乱码一区二区三区软件| 中文无字幕一区二区三区| 日本一区二区动态图| 亚洲欧洲在线观看av| 一区二区不卡在线播放 | 久久这里只有精品视频网| 99re这里都是精品| 色婷婷综合久久久| 欧美日韩国产区一| 精品奇米国产一区二区三区| 国产欧美1区2区3区| 亚洲美女淫视频| 免费成人av资源网| 成人夜色视频网站在线观看| 在线精品视频一区二区三四| 日韩一级片在线观看| 国产欧美日韩在线看| 夜夜精品浪潮av一区二区三区| 首页国产丝袜综合| 国产福利一区二区三区视频| 色综合久久久久久久久久久| 欧美一级淫片007| 中文字幕av一区 二区| 亚洲成人免费电影| 粉嫩蜜臀av国产精品网站| 欧美日韩一区高清| 欧美国产激情二区三区| 亚洲国产成人av网| 国产成人av电影在线观看| 欧美日韩一区二区欧美激情| 久久精品视频免费观看| 亚洲a一区二区| 成人黄色电影在线| 日韩欧美成人午夜| 亚洲手机成人高清视频| 91丝袜高跟美女视频| 日韩一区二区影院| 国产欧美日产一区| 成人午夜免费电影| 正在播放亚洲一区| 中文字幕在线观看不卡| 精品一区二区在线播放| 欧美色图激情小说| 国产精品欧美一级免费| 麻豆视频一区二区| 欧美性受xxxx黑人xyx| 中文字幕+乱码+中文字幕一区| 日韩精品一级中文字幕精品视频免费观看 | 久久一二三国产| 五月婷婷激情综合网| 国产91清纯白嫩初高中在线观看| 91麻豆精品91久久久久同性| 亚洲乱码中文字幕| 成人手机电影网| 久久蜜臀精品av| 久久精品av麻豆的观看方式| 欧美无砖专区一中文字| 中文字幕综合网| 粗大黑人巨茎大战欧美成人| 精品免费一区二区三区| 亚洲高清免费一级二级三级| 国产三级欧美三级日产三级99 | 国产精品二三区| 久久国产夜色精品鲁鲁99| 欧美日韩精品一区二区三区 | 亚洲线精品一区二区三区八戒| 国产91精品在线观看| 久久网这里都是精品| 麻豆国产精品视频| 欧美一区二区三区免费观看视频| 亚洲一二三区不卡| 欧美伊人久久大香线蕉综合69| 中文字幕在线不卡国产视频| 丁香天五香天堂综合| 中文字幕不卡的av| 菠萝蜜视频在线观看一区| 亚洲国产精品成人综合| 国产伦精一区二区三区| 久久久www成人免费毛片麻豆| 久久成人免费电影| www国产亚洲精品久久麻豆| 另类小说综合欧美亚洲| 欧美成人精精品一区二区频| 老司机午夜精品99久久| 国产成人在线视频网址| 亚洲黄色性网站| 91老师片黄在线观看| 久久久夜色精品亚洲| 韩国一区二区三区| 久久影院电视剧免费观看| 国产成人亚洲精品狼色在线| 久久久久久**毛片大全| 成人一区在线观看| 亚洲欧美成人一区二区三区| 欧美中文字幕一区二区三区| 亚洲国产精品久久艾草纯爱| 在线综合+亚洲+欧美中文字幕| 五月天网站亚洲| 制服丝袜一区二区三区| 久久99精品久久久久久国产越南 | 91小视频在线| 亚洲综合网站在线观看| 欧美日高清视频| 精品在线观看视频| 久久久99免费| 99久精品国产| 视频一区视频二区中文| 日韩欧美一级精品久久| 国产精品中文字幕欧美| 亚洲欧洲www| 欧美视频一区二区三区四区| 免费成人在线视频观看| 国产日韩欧美a| 欧美中文字幕亚洲一区二区va在线| 天堂成人国产精品一区| 久久久久久久久久久99999| 91欧美激情一区二区三区成人| 午夜视频一区二区三区| 26uuu欧美| 色乱码一区二区三区88| 日本亚洲三级在线| 国产精品久久久久久久久搜平片| 91福利资源站| 日韩你懂的电影在线观看| 欧美电视剧免费全集观看| 欧美一区二区视频免费观看| 欧美日韩一区中文字幕| 狠狠色伊人亚洲综合成人| 国产精品久久久久久一区二区三区 | 亚洲日本在线观看| 欧美精三区欧美精三区| 国产不卡视频在线播放| 午夜欧美在线一二页| 国产精品免费aⅴ片在线观看| 欧美日韩在线不卡| 不卡一区二区三区四区| 日韩av一区二| 亚洲男人天堂一区| 久久精品亚洲精品国产欧美 | 久久久久久久久久看片| 欧美亚洲自拍偷拍| 成人一区二区在线观看| 免费看欧美美女黄的网站| 亚洲伦理在线精品| 国产亚洲成aⅴ人片在线观看| 欧美视频一区二区| 成人av在线影院| 国产伦精品一区二区三区免费迷| 亚洲午夜电影在线观看| 中文字幕中文在线不卡住| 精品国产乱码久久久久久夜甘婷婷 | 337p亚洲精品色噜噜噜| 色激情天天射综合网| 国产精品99精品久久免费| 麻豆成人免费电影| 亚洲sss视频在线视频| 亚洲丝袜精品丝袜在线| 亚洲国产精品t66y| 精品国产乱码久久久久久久| 欧美精品免费视频| 色婷婷久久综合| 91麻豆自制传媒国产之光| 丁香激情综合国产| 国内久久婷婷综合| 久久国产麻豆精品| 日韩精彩视频在线观看| 亚洲制服丝袜av| 亚洲女人小视频在线观看| 国产拍揄自揄精品视频麻豆| 精品国产一区二区三区久久久蜜月| 欧美群妇大交群中文字幕| 色综合天天综合| 91片在线免费观看| 91在线观看下载| 99热这里都是精品| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美唯美清纯偷拍| 欧美亚洲丝袜传媒另类|