Re: add own program to ports + help with port / program
On Sun, 13 Sep 2009 21:38:00 +0200, Stefan Miklosovic wrote: > I am about writing shell script which adds system account > by tens (even hundreds). Interesting and useful tool. I'm sure many sysadmins have created such tools for their own needs, but it wouldn't be bad to have one publically available from the ports collection. > Password are generated by apg program In order to employ an alternate password generation program (e. g. pwgen), you could even add an entry to your configuration file. > I want to write this program but I do not know if I do it correct and I need > some > feedback about programming style or just some info what do you think about > it. Style is highly debatable and is discussed ocassionally on this list. But finally, YOU are the programmer and YOU are the one who decides about style. Programming tips to mainly rely on which programming language you use. For example, if you're using C, I would suggest you to only use "safe functions" (e. g. no strcpy() function) and always check return values (e. g. fopen(), fputs() and fclose() functions, if you use them for accessing files). In case you are using threads, check that your program is "thread safe". Testing as much as possible is important because you're writing a program that is acting on system level (root) when it does "simply" create user accounts. > At this time, there is absence of manual, but if you track code, I think > you understand it. In order to comply to FreeBSD's philosophy of quality, you should, if your program is complete, take the time to write a manpage. As a developer, I always loved FreeBSD for its excellent documentation. Don't do it "the Linux way" - leave documentation to the Web, a Wiki, or the users. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
add own program to ports + help with port / program
hi list, I am about writing shell script which adds system account by tens (even hundreds). Info about added accounts is stored in external file which has syntax like this account-name:comment:email-addres Briefly, account-name is name of account comment field is comment which appears in /etc/passwd comment field email-address is address where info about just created account is sent (optional) eg. joe:Joe Brown:j...@something.com mark:Mark Red:m...@nowhere.org tim:Tim Yellow:ti...@example.com Script is checking file syntax and if syntax is bad, it exits. If it is ok, accounts is being created. You can modify a lot of infos, these are stored in config file in /usr/local/etc/pwgroup.conf, eg # output file with passwords of newly # created user accounts PASSWD_FILE="passwords" # uid of first created user UID="2000" # root home dir of users HOME_DIR="/home" # comment for users, appears in /etc/passwd # in comment field COMMENT="" # primary group for users, if empty, # primary group will be a user name GROUP="users" # comma separated list of groups # users should be a member of GROUPLIST="" # shell for users SHELL="/bin/csh" # use quotas QUOTAS="NO" # hard quote limit QUOTA_HARD="1536" # soft quote limit QUOTA_SOFT="1024" # disk device upon which users are created DISK_DEV="/home" # expiration date of accounts ACCOUNT_EXP="30-Jun-2010" # length of password PASSWORD_LENGTH="8" == as you can see, you can set quotas for users, account expiration of accounts, password length, shell and so on. Variables in config file are default, if you do not overwrite some at command line. some examples: # pwgrp -a -f users -c "unix begginer" -s /usr/local/bin/bash -q -qh 2048 -l 10 (adding users) # pwgrp -r -f remove_users (list of users for removing) Password are generated by apg program Quotas are set by setquotas. The main reason I write this mail is to make some feedback about program to me and even test it and comment it. I want to write this program but I do not know if I do it correct and I need some feedback about programming style or just some info what do you think about it. At this time, there is absence of manual, but if you track code, I think you understand it. Any ideas are highly appreciated. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"