#!/usr/bin/perl #*************************************************************************** # ZEPTOOS:zepto-info # This file is part of ZeptoOS: The Small Linux for Big Computers. # See www.mcs.anl.gov/zeptoos for more information. # ZEPTOOS:zepto-info # # ZEPTOOS:zepto-fillin # $Id: mkpasswd.pl,v 1.17 2005/11/11 20:01:57 beckman Exp $ # ZeptoOS_Version: 1.2 # ZeptoOS_Heredity: FOSS_ORIG # ZeptoOS_License: GPL # ZEPTOOS:zepto-fillin # # ZEPTOOS:zepto-gpl # Copyright: Argonne National Laboratory, Department of Energy, # and University of Chicago. 2004, 2005 # ZeptoOS License: GPL # # This software is free. See the file ZeptoOS/misc/license.GPL # for complete details on your rights to copy, modify, and use this # software. # ZEPTOOS:zepto-gpl #*************************************************************************** # This small program creates a passwd file in the current directory # which is copied by create-ramdisk.sh to new ramdisk. The password # file contains three users: root, your username and nobody. root and # your username entry have a plain passwd string crypted from passwd # you entered. # NOTE: don't use important password. A plain crypted string stored # into passwd file. use strict; use English; my $username = getpwuid($UID); my $word; PASSENTRY: print "Please enter password for ramdisk.\n"; # root and $username system "stty -echo"; print "New password:"; chomp($word = ); if( length($word) < 6 ) { system "stty echo"; printf "\npasswd is too short!\n\n"; goto PASSENTRY; } print "\n"; system "stty -echo"; print "Retype new password:"; my $word2; chomp($word2 = ); system "stty echo"; if( $word != $word2 ) { print "\nsorry. password does not match.\n"; goto PASSENTRY; } my $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64] ; my $passwd = crypt( $word, $salt ) ; system "stty echo"; my $passwdfn = "ramdisk-passwd"; open(FH, ">${passwdfn}") or die "Unable to open ${passwdfn}"; print FH "root:${passwd}:0:0:root:/:/bin/sh\n"; print FH "${username}:${passwd}:${UID}:100:${username}:/:/bin/sh\n"; print FH "rpcuser:*:29:29:RPC Service User:/var/lib/nfs:\n"; print FH "sshd:*:74:74:Privilege-separated SSH:/var/empty/sshd:/bin/sh\n"; print FH "nobody:*:99:99:Nobody:/:\n"; close(FH); my $pwd = `pwd`; chomp($pwd); print "\n${pwd}/${passwdfn} has been created.\n"; exit 0;