Koozali.org: home of the SME Server

/etc/passwd to lat-tools formatting

Offline mjlyon

  • *
  • 17
  • +0/-0
/etc/passwd to lat-tools formatting
« on: May 27, 2009, 05:59:41 PM »
Does anyone have any experience using perl or any other regular expression parsers to convert an /etc/passwd file into a format compatible for use with lat-users so I can batch import?


Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: /etc/passwd to lat-tools formatting
« Reply #1 on: May 27, 2009, 10:14:55 PM »
Does anyone have any experience using perl or any other regular expression parsers to convert an /etc/passwd file into a format compatible for use with lat-users so I can batch import?
I am not sure if the /etc/passwd file contains enough information, have a look at the examples in /usr/doc/lazy-admin-tools/ it seems that you need at least the login name, firstname and lastname, the first is in there, the latter two could be in there but it is one field, so you would need to define what you want to do with that field, split it where possible, or do not split at all and add it to either firstname or lastname field.

This is just from looking at the docs as I have never used the toolkit.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: /etc/passwd to lat-tools formatting
« Reply #2 on: May 27, 2009, 10:21:12 PM »
A little google-ing on 'awk etc passwd' results in this page: http://www.ibm.com/developerworks/library/l-awk1.html

From which you could device some minimal example like this for instance:

Code: [Select]
awk -F":" '{ print $1 "|" $5 }' /etc/passwd
which would output something like this:

Code: [Select]
[root@smetest-i386 ~]# awk -F":" '{ print $1 "|" $5 }' /etc/passwd
root|root
bin|bin
daemon|daemon
adm|adm
lp|lp
mail|mail
news|news
uucp|uucp
operator|operator
games|games
gopher|gopher
ftp|FTP User
nobody|Nobody
dbus|System message bus
vcsa|virtual console memory owner
mysql|MySQL Server
alias|
qmaild|
qmaill|
qmailp|
qmailq|
qmailr|
qmails|
haldaemon|HAL daemon
apache|Apache
ldap|LDAP User
pcap|
nut|Network UPS Tools
clamav|Clam Anti Virus Checker
www|e-smith web server
admin|e-smith administrator
public|e-smith guest
smelog|sme log user
ntp|
rpm|
cvmlog|cvm output log user
dnscache|DNScache user
dnslog|DNS log user
dovecot|dovecot
stunnel|chrooted stunnel user user
imaplog|imap output log user
radiusd|radiusd user
sshd|Privilege-separated SSH
squid|
smelastsys|sme last system user marker
dns|Name server
qpsmtpd|qpsmtpd system user
spamd|spamassassin daemon user
[root@smetest-i386 ~]#
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)