Codebase list ldapscripts / f2786fd
Imported Upstream version 1.9.0 Alexander GQ Gerasiov 14 years ago
30 changed file(s) with 249 addition(s) and 88 deletion(s). Raw diff Collapse all Expand all
0 2009/07/16 : ldapscripts 1.9.0
1 - Fixed a few lines in man pages
2 - Changed PASSWORDGEN's default value to not use uuencode anymore
3 - Use 'id' command instead of 'logname' to guess current user (used by ldapfinger and ldapid)
4 Be careful if you want to act on your own account using su/sudo !
5 - New DESTDIR variable in Makefile, to specify a global chroot as a target directory for installation
6
7 => thanks to Alexander GQ Gerasiov for those 4 fixes !
8
9 - New 'ldapgid' command to display a group's list of IDs
10
011 2008/08/10 : ldapscripts 1.8.0
112 - No changes since 1.8.0rc1, but tests have been performed
213 on Debian and Ubuntu with success, so let's rock !
1717 # USA.
1818
1919 # Configuration / variables section
20 DESTDIR =
2021 PREFIX = /usr/local
2122
2223 # Identity
2324 SHELL=/bin/sh
2425 NAME = ldapscripts
2526 #SUFFIX = -devel
26 VERSION = 1.8.0
27 VERSION = 1.9.0
2728
2829 # Default installation paths
2930 SBINDIR = $(PREFIX)/sbin
3637 ETCFILE = ldapscripts.conf
3738 PWDFILE = ldapscripts.passwd
3839 SBINFILES = ldapdeletemachine ldapmodifygroup ldapsetpasswd lsldap ldapadduser \
39 ldapdeleteuser ldapsetprimarygroup ldapfinger ldapid ldapmodifymachine \
40 ldapdeleteuser ldapsetprimarygroup ldapfinger ldapid ldapgid ldapmodifymachine \
4041 ldaprenamegroup ldapaddgroup ldapaddusertogroup ldapdeleteuserfromgroup \
4142 ldapinit ldapmodifyuser ldaprenamemachine ldapaddmachine ldapdeletegroup \
4243 ldaprenameuser
4344 MAN1FILES = ldapdeletemachine.1 ldapmodifymachine.1 ldaprenamemachine.1 ldapadduser.1 \
44 ldapdeleteuserfromgroup.1 ldapfinger.1 ldapid.1 ldapmodifyuser.1 lsldap.1 \
45 ldapdeleteuserfromgroup.1 ldapfinger.1 ldapid.1 ldapgid.1 ldapmodifyuser.1 lsldap.1 \
4546 ldapaddusertogroup.1 ldaprenameuser.1 ldapinit.1 ldapsetpasswd.1 ldapaddgroup.1 \
4647 ldapdeletegroup.1 ldapsetprimarygroup.1 ldapmodifygroup.1 ldaprenamegroup.1 \
4748 ldapaddmachine.1 ldapdeleteuser.1
5657 help:
5758 @echo "Usage: make [VARIABLE=<value>] <target>"
5859 @echo "Valid variables :"
59 @echo " PREFIX : main target directory for installation (default = /usr/local)"
60 @echo " DESTDIR : root target directory to install to (default = *empty*)"
61 @echo " PREFIX : main target directory within DESTDIR (default = /usr/local)"
6062 @echo " SBINDIR : where to install scripts (default = PREFIX/sbin)"
6163 @echo " MANDIR : where to install man pages (default = PREFIX/man)"
6264 @echo " ETCDIR : where to install the configuration file (default = PREFIX/etc/ldapscripts)"
9092 # Install targets
9193 install: installsbin installman installetc installlib
9294 installsbin: configure
93 @echo -n 'Installing scripts into $(SBINDIR)... '
94 @install -d -m 755 '$(SBINDIR)' 2>/dev/null
95 @for i in $(SBINFILES) ; do \
96 install -m 750 "sbin/$$i.patched" "$(SBINDIR)/$$i" ; \
95 @echo -n 'Installing scripts into $(DESTDIR)$(SBINDIR)... '
96 @install -d -m 755 '$(DESTDIR)$(SBINDIR)' 2>/dev/null
97 @for i in $(SBINFILES) ; do \
98 install -m 750 "sbin/$$i.patched" "$(DESTDIR)$(SBINDIR)/$$i" ; \
9799 done
98100 @echo 'ok.'
99101
100102 installman:
101 @echo -n 'Installing man files into $(MANDIR)... '
102 @install -d -m 755 '$(MANDIR)/man1' 2>/dev/null
103 @echo -n 'Installing man files into $(DESTDIR)$(MANDIR)... '
104 @install -d -m 755 '$(DESTDIR)$(MANDIR)/man1' 2>/dev/null
103105 @for i in $(MAN1FILES) ; do \
104 cat "man/man1/$$i" | gzip - > "$(MANDIR)/man1/`basename $$i`.gz" ; \
105 done
106 @install -d -m 755 '$(MANDIR)/man5' 2>/dev/null
106 cat "man/man1/$$i" | gzip - > "$(DESTDIR)$(MANDIR)/man1/`basename $$i`.gz" ; \
107 done
108 @install -d -m 755 '$(DESTDIR)$(MANDIR)/man5' 2>/dev/null
107109 @for i in $(MAN5FILES) ; do \
108 cat "man/man5/$$i" | gzip - > "$(MANDIR)/man5/`basename $$i`.gz" ; \
110 cat "man/man5/$$i" | gzip - > "$(DESTDIR)$(MANDIR)/man5/`basename $$i`.gz" ; \
109111 done
110112 @echo 'ok.'
111113
112114 installetc: configure
113 @echo -n 'Installing configuration files into $(ETCDIR)... '
114 @install -d -m 755 '$(ETCDIR)' 2>/dev/null
115 @install -m 440 'etc/$(ETCFILE).patched' '$(ETCDIR)/$(ETCFILE).sample'
116 @if [ ! -f '$(ETCDIR)/$(ETCFILE)' ]; then \
117 install -m 640 '$(ETCDIR)/$(ETCFILE).sample' '$(ETCDIR)/$(ETCFILE)'; \
118 fi
119 @install -m 440 -b 'etc/$(PWDFILE)' '$(ETCDIR)/$(PWDFILE).sample'
120 @if [ ! -f '$(ETCDIR)/$(PWDFILE)' ]; then \
121 install -m 640 '$(ETCDIR)/$(PWDFILE).sample' '$(ETCDIR)/$(PWDFILE)'; \
115 @echo -n 'Installing configuration files into $(DESTDIR)$(ETCDIR)... '
116 @install -d -m 755 '$(DESTDIR)$(ETCDIR)' 2>/dev/null
117 @install -m 440 'etc/$(ETCFILE).patched' '$(DESTDIR)$(ETCDIR)/$(ETCFILE).sample'
118 @if [ ! -f '$(DESTDIR)$(ETCDIR)/$(ETCFILE)' ]; then \
119 install -m 640 '$(DESTDIR)$(ETCDIR)/$(ETCFILE).sample' '$(DESTDIR)$(ETCDIR)/$(ETCFILE)'; \
120 fi
121 @install -m 440 -b 'etc/$(PWDFILE)' '$(DESTDIR)$(ETCDIR)/$(PWDFILE).sample'
122 @if [ ! -f '$(DESTDIR)$(ETCDIR)/$(PWDFILE)' ]; then \
123 install -m 640 '$(DESTDIR)$(ETCDIR)/$(PWDFILE).sample' '$(DESTDIR)$(ETCDIR)/$(PWDFILE)'; \
122124 fi
123125 @for i in $(TMPLFILES) ; do \
124 install -m 440 "etc/$$i" '$(ETCDIR)' ; \
126 install -m 440 "etc/$$i" '$(DESTDIR)$(ETCDIR)' ; \
125127 done
126128 @echo 'ok.'
127129
128130 installlib: configure
129 @echo -n 'Installing library files into $(LIBDIR)... '
130 @install -d -m 755 '$(LIBDIR)' 2>/dev/null
131 @install -m 440 'lib/$(RUNFILE).patched' '$(LIBDIR)/$(RUNFILE)'
131 @echo -n 'Installing library files into $(DESTDIR)$(LIBDIR)... '
132 @install -d -m 755 '$(DESTDIR)$(LIBDIR)' 2>/dev/null
133 @install -m 440 'lib/$(RUNFILE).patched' '$(DESTDIR)$(LIBDIR)/$(RUNFILE)'
132134 @echo 'ok.'
133135
134136 # Uninstall targets
135137 deinstall: uninstall
136138 uninstall: uninstallsbin uninstallman uninstalletc uninstalllib
137139 uninstallsbin:
138 @echo -n 'Uninstalling scripts from $(SBINDIR)... '
139 @for i in $(SBINFILES) ; do \
140 rm -f "$(SBINDIR)/$$i" ; \
141 done
142 @rmdir '$(SBINDIR)' 2>/dev/null || true
140 @echo -n 'Uninstalling scripts from $(DESTDIR)$(SBINDIR)... '
141 @for i in $(SBINFILES) ; do \
142 rm -f "$(DESTDIR)$(SBINDIR)/$$i" ; \
143 done
144 @rmdir '$(DESTDIR)$(SBINDIR)' 2>/dev/null || true
143145 @echo 'ok.'
144146
145147 uninstallman:
146 @echo -n 'Uninstalling man files from $(MANDIR)... '
148 @echo -n 'Uninstalling man files from $(DESTDIR)$(MANDIR)... '
147149 @for i in $(MAN1FILES) ; do \
148 rm -f "$(MANDIR)/man1/`basename $$i`.gz" ; \
149 done
150 @rmdir '$(MANDIR)/man1' 2>/dev/null || true
150 rm -f "$(DESTDIR)$(MANDIR)/man1/`basename $$i`.gz" ; \
151 done
152 @rmdir '$(DESTDIR)$(MANDIR)/man1' 2>/dev/null || true
151153 @for i in $(MAN5FILES) ; do \
152 rm -f "$(MANDIR)/man5/`basename $$i`.gz" ; \
153 done
154 @rmdir '$(MANDIR)/man5' 2>/dev/null || true
154 rm -f "$(DESTDIR)$(MANDIR)/man5/`basename $$i`.gz" ; \
155 done
156 @rmdir '$(DESTDIR)$(MANDIR)/man5' 2>/dev/null || true
155157 @rmdir '$(MANDIR)' 2>/dev/null || true
156158 @echo 'ok.'
157159
158160 uninstalletc:
159 @echo -n 'Uninstalling configuration files from $(ETCDIR)... '
160 @if cmp -s '$(ETCDIR)/$(ETCFILE)' '$(ETCDIR)/$(ETCFILE).sample'; then \
161 rm -f '$(ETCDIR)/$(ETCFILE)'; \
162 fi
163 @rm -f '$(ETCDIR)/$(ETCFILE).sample'
164 @if cmp -s '$(ETCDIR)/$(PWDFILE)' '$(ETCDIR)/$(PWDFILE).sample'; then \
165 rm -f '$(ETCDIR)/$(PWDFILE)'; \
166 fi
167 @rm -f '$(ETCDIR)/$(PWDFILE).sample'
161 @echo -n 'Uninstalling configuration files from $(DESTDIR)$(ETCDIR)... '
162 @if cmp -s '$(DESTDIR)$(ETCDIR)/$(ETCFILE)' '$(DESTDIR)$(ETCDIR)/$(ETCFILE).sample'; then \
163 rm -f '$(DESTDIR)$(ETCDIR)/$(ETCFILE)'; \
164 fi
165 @rm -f '$(DESTDIR)$(ETCDIR)/$(ETCFILE).sample'
166 @if cmp -s '$(DESTDIR)$(ETCDIR)/$(PWDFILE)' '$(DESTDIR)$(ETCDIR)/$(PWDFILE).sample'; then \
167 rm -f '$(DESTDIR)$(ETCDIR)/$(PWDFILE)'; \
168 fi
169 @rm -f '$(DESTDIR)$(ETCDIR)/$(PWDFILE).sample'
168170 @for i in $(TMPLFILES) ; do \
169 rm -f "$(ETCDIR)/$$i" ; \
170 done
171 @rmdir '$(ETCDIR)' 2>/dev/null || true
171 rm -f "$(DESTDIR)$(ETCDIR)/$$i" ; \
172 done
173 @rmdir '$(DESTDIR)$(ETCDIR)' 2>/dev/null || true
172174 @echo 'ok.'
173175
174176 uninstalllib:
175 @echo -n 'Uninstalling library files from $(LIBDIR)... '
176 @rm -f '$(LIBDIR)/$(RUNFILE)'
177 @rmdir '$(LIBDIR)' 2>/dev/null || true
177 @echo -n 'Uninstalling library files from $(DESTDIR)$(LIBDIR)... '
178 @rm -f '$(DESTDIR)$(LIBDIR)/$(RUNFILE)'
179 @rmdir '$(DESTDIR)$(LIBDIR)' 2>/dev/null || true
178180 @echo 'ok.'
179181
180182 # Clean targets
123123 sbin/ldapsetpasswd : modifies a POSIX user account's password in LDAP
124124 sbin/ldapfinger : displays a user/machine/group POSIX account's details
125125 sbin/ldapid : displays a user's list of IDs
126 sbin/ldapgid : displays a group's list of IDs
126127
127128 Author / Licence :
128129 ******************
0 1.8.0
0 1.9.0
4747 # Command-line used to generate a password for added users (you may use %u for username here)
4848 # WARNING !!!! This is evaluated, everything specified here will be run !
4949 # Special value "<ask>" will ask for a password interactively
50 PASSWORDGEN="head -c8 /dev/random | uuencode -m - | sed -n '2s|=*$||;2p' | sed -e 's|+||g' -e 's|/||g'"
50 PASSWORDGEN="cat /dev/random | LC_ALL=C tr -dc 'a-zA-Z0-9' | head -c8"
51 #PASSWORDGEN="head -c8 /dev/random | uuencode -m - | sed -n '2s|=*$||;2p' | sed -e 's|+||g' -e 's|/||g'"
52 #PASSWORDGEN="pwgen"
5153 #PASSWORDGEN="echo changeme"
5254 #PASSWORDGEN="echo %u"
5355 #PASSWORDGEN="<ask>"
617617 end_die "You must have uuencode installed before running these scripts"
618618
619619 # Pseudo-random number generator
620 [ ! -e /dev/random ] && end_die "You need a /dev/random special file to run these scripts"
620 [ ! -e /dev/random ] && end_die "You need a /dev/random special file to run these scripts"
621621
622622 # Set USER variable to the real user (do not trust current $USER value)
623 USER=`logname`
623 USER=`id -nu`
624624
625625 # Check for bindpwd file
626626 if [ ! -f "$BINDPWDFILE" ] || [ ! -r "$BINDPWDFILE" ]
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapaddgroup 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapaddgroup \- adds a POSIX group entry to LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapaddmachine 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapaddmachine \- adds a POSIX machine (user$) account to LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapadduser 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapadduser \- adds a POSIX user account to LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapaddusertogroup 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapaddusertogroup \- adds a memberUid attribute to a POSIX group in LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapdeletegroup 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapdeletegroup \- deletes a POSIX group account from LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapdeletemachine 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapdeletemachine \- deletes a POSIX machine (user$) account from LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapdeleteuser 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapdeleteuser \- deletes a POSIX user account from LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapdeleteuserfromgroup 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapdeleteuserfromgroup \- deletes a memberUid attribute from a POSIX group in LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapfinger 1 "February 1, 2007"
22 .LO 1
2322
2423 .SH NAME
2524 ldapfinger \- displays a user/machine/group POSIX account's details.
4342 Look for machines only (by default, search the whole directory).
4443
4544 .SH "SEE ALSO"
46 lsldap(1), ldapid(1), ldapscripts(5).
45 lsldap(1), ldapid(1), ldapgid(1), ldapscripts(5).
4746
4847 .SH AVAILABILITY
4948 The ldapscripts are provided under the GNU General Public License v2 (see COPYING for more details).
0 .\" Copyright (C) 2009 Ganaƫl LAPLANCHE
1 .\"
2 .\" This program is free software; you can redistribute it and/or
3 .\" modify it under the terms of the GNU General Public License
4 .\" as published by the Free Software Foundation; either version 2
5 .\" of the License, or (at your option) any later version.
6 .\"
7 .\" This program is distributed in the hope that it will be useful,
8 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
9 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 .\" GNU General Public License for more details.
11 .\"
12 .\" You should have received a copy of the GNU General Public License
13 .\" along with this program; if not, write to the Free Software
14 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
15 .\" USA.
16 .\"
17 .\" Ganael Laplanche
18 .\" ganael.laplanche@martymac.com
19 .\" http://contribs.martymac.com
20 .\"
21 .TH ldapgid 1 "January 23, 2009"
22
23 .SH NAME
24 ldapgid \- displays a group's list of IDs the way ldapid(1) does.
25
26 .SH SYNOPSIS
27 .B ldapgid
28 .RB [-P] <groupname | gid>
29
30 .SH DESCRIPTION
31 .TP
32 The following is displayed : gid=gidNumber(cn) users(primary)=uidNumber(uid)[,uidNumber(uid)...] users(secondary)=uidNumber(uid)[,uidNumber(uid)...].
33 .TP
34 users(primary) lists users having the group declared as their primary group. users(secondary) lists users using the group as a secondary one.
35
36 .SH OPTIONS
37 .TP
38 .B <groupname | gid>
39 Group name or GID of a group to show information about.
40 .TP
41 .B [-P]
42 Display group information as a /etc/group file entry.
43
44 .SH "SEE ALSO"
45 ldapid(1), lsldap(1), ldapfinger(1), ldapscripts(5).
46
47 .SH AVAILABILITY
48 The ldapscripts are provided under the GNU General Public License v2 (see COPYING for more details).
49 The latest version of the ldapscripts is available on :
50 .B http://contribs.martymac.com
51
52 .SH BUGS
53 No bug known.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapid 1 "July 1, 2008"
22 .LO 1
2322
2423 .SH NAME
2524 ldapid \- displays a user's list of IDs the way 'id' does.
2625 .TP
27 The following is displayed : uidNumber(uid) gidNumber(cn) groups=gidNumber(cn)[,secondary groups...].
26 The following is displayed : uid=uidNumber(uid) gid=gidNumber(cn) groups=gidNumber(cn)[,gidNumber(cn)...].
2827
2928 .SH SYNOPSIS
3029 .B ldapid
3938 Display user information as a password file entry.
4039
4140 .SH "SEE ALSO"
42 lsldap(1), ldapfinger(1), ldapscripts(5).
41 ldapgid(1), lsldap(1), ldapfinger(1), ldapscripts(5).
4342
4443 .SH AVAILABILITY
4544 The ldapscripts are provided under the GNU General Public License v2 (see COPYING for more details).
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapinit 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapinit \- initializes the LDAP directory with a minimal tree.
4039 Skip root DN creation (create only regular OUs).
4140
4241 .SH "SEE ALSO"
43 lsldap(1), ldapfinger(1), ldapid(1), ldapscripts(5).
42 lsldap(1), ldapfinger(1), ldapid(1), ldapgid(1), ldapscripts(5).
4443
4544 .SH AVAILABILITY
4645 The ldapscripts are provided under the GNU General Public License v2 (see COPYING for more details).
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapmodifygroup 1 "August 22, 2007"
22 .LO 1
2322
2423 .SH NAME
2524 ldapmodifygroup \- modifies a POSIX group account in LDAP interactively
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapmodifymachine 1 "August 22, 2007"
22 .LO 1
2322
2423 .SH NAME
2524 ldapmodifymachine \- modifies a POSIX machine account in LDAP interactively
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapmodifyuser 1 "August 22, 2007"
22 .LO 1
2322
2423 .SH NAME
2524 ldapmodifyuser \- modifies a POSIX user account in LDAP interactively
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldaprenamegroup 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldaprenamegroup \- renames a POSIX group in LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldaprenamemachine 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldaprenamemachine \- renames a POSIX machine account in LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH _ldaprenameuser 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 _ldaprenameuser \- renames a POSIX user account in LDAP.
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapsetpasswd 1 "November 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapsetpasswd \- modifies a POSIX user account's password in LDAP.
3938 be prompted for a password that will be changed using the ldappasswd(1) command.
4039
4140 .SH "SEE ALSO"
42 ldapfinger(1), ldapid(1), ldapscripts(5).
41 ldapfinger(1), ldapid(1), ldapgid(1), ldapscripts(5).
4342
4443 .SH AVAILABILITY
4544 The ldapscripts are provided under the GNU General Public License v2 (see COPYING for more details).
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapsetprimarygroup 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapsetprimarygroup \- modifies the gidNumber of a POSIX user or machine account in LDAP (sets a user's primary group in LDAP).
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH lsldap 1 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 lsldap \- performs a *big* query on the LDAP directory.
4342 List machines only (by default, try to list the whole directory).
4443
4544 .SH "SEE ALSO"
46 ldapfinger(1), ldapid(1), ldapscripts(5).
45 ldapfinger(1), ldapid(1), ldapgid(1), ldapscripts(5).
4746
4847 .SH AVAILABILITY
4948 The ldapscripts are provided under the GNU General Public License v2 (see COPYING for more details).
1919 .\" http://contribs.martymac.com
2020 .\"
2121 .TH ldapscripts 5 "January 1, 2006"
22 .LO 1
2322
2423 .SH NAME
2524 ldapscripts \- Scripts to manage POSIX accounts in your LDAP directory.
0 #!/bin/sh
1
2 # ldapgid : displays a group's list of IDs
3
4 # Copyright (C) 2009 Ganaƫl LAPLANCHE
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 # USA.
20
21 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]
22 then
23 echo "Usage : $0 [-P] <groupname | gid>"
24 exit 1
25 fi
26
27 # Source runtime file
28 _RUNTIMEFILE="/usr/lib/ldapscripts/runtime"
29 . "$_RUNTIMEFILE"
30
31 # Parse options
32 case "$1" in
33 "-P")
34 # Passwd-like display requested
35 [ -z "$2" ] && end_die 'Please specify a GID or a group name'
36 _GROUP="$2"
37 ;;
38 *)
39 # Standard display requested
40 _GROUP="$1"
41 ;;
42 esac
43
44 # Check groupname
45 _findentry "$GSUFFIX,$SUFFIX" "(&(objectClass=posixGroup)(|(cn=$_GROUP)(gidNumber=$_GROUP)))"
46 [ -z "$_ENTRY" ] && end_die "Group $_GROUP not found in LDAP"
47
48 # Get each (common) attribute
49 # gidNumber
50 _getattribute "$_ENTRY" "gidNumber"
51 [ -z "$_ATTRIBUTE" ] && end_die "Error getting group attribute from LDAP (gidNumber)"
52 _GIDNUMBER="$_ATTRIBUTE"
53 # cn
54 _getattribute "$_ENTRY" "cn"
55 [ -z "$_ATTRIBUTE" ] && end_die "Error getting group attribute from LDAP (cn)"
56 _CN="$_ATTRIBUTE"
57
58 case "$1" in
59 "-P")
60 # Passwd-like display requested
61 _OUTPUT="$_CN:*:$_GIDNUMBER:"
62 # User list (secondary group)
63 _SECONDARYUIDS=`_ldapsearch "$_ENTRY" "" memberUid | grep "memberUid: " | sed "s|memberUid: ||"`
64 _FIRSTPASS=""
65 for _SECONDARYUID in $_SECONDARYUIDS
66 do
67 if [ -z "$_FIRSTPASS" ]
68 then
69 _OUTPUT="$_OUTPUT$_SECONDARYUID"
70 _FIRSTPASS="done"
71 else
72 _OUTPUT="$_OUTPUT,$_SECONDARYUID"
73 fi
74 done
75 ;;
76 *)
77 # Standard display requested
78 _OUTPUT="gid=$_GIDNUMBER($_CN)"
79 # User list (primary group)
80 _PRIMARYUIDS=`_ldapsearch "$USUFFIX,$SUFFIX" "(&(objectClass=posixAccount)(gidNumber=$_GIDNUMBER))" uidNumber | grep "uidNumber: " | sed "s|uidNumber: ||"`
81 _FIRSTPASS=""
82 for _PRIMARYUID in $_PRIMARYUIDS
83 do
84 _uidtouser "$_PRIMARYUID"
85 if [ -z "$_FIRSTPASS" ]
86 then
87 _OUTPUT="$_OUTPUT users(primary)=$_PRIMARYUID($_UID)"
88 _FIRSTPASS="done"
89 else
90 _OUTPUT="$_OUTPUT,$_PRIMARYUID($_UID)"
91 fi
92 done
93 # User list (secondary group)
94 _SECONDARYUIDS=`_ldapsearch "$_ENTRY" "" memberUid | grep "memberUid: " | sed "s|memberUid: ||"`
95 _FIRSTPASS=""
96 for _SECONDARYUID in $_SECONDARYUIDS
97 do
98 _usertouid "$_SECONDARYUID"
99 if [ -z "$_FIRSTPASS" ]
100 then
101 _OUTPUT="$_OUTPUT users(secondary)=$_UID($_SECONDARYUID)"
102 _FIRSTPASS="done"
103 else
104 _OUTPUT="$_OUTPUT,$_UID($_SECONDARYUID)"
105 fi
106 done
107 ;;
108 esac
109
110 # Display result
111 echo $_OUTPUT && end_ok
5959 # Get each (common) attribute
6060 # uidNumber
6161 _getattribute "$_ENTRY" "uidNumber"
62 [ -z "$_ATTRIBUTE" ] && end_die "Error getting user attributes from LDAP (uidNumber)"
62 [ -z "$_ATTRIBUTE" ] && end_die "Error getting user attribute from LDAP (uidNumber)"
6363 _UIDNUMBER="$_ATTRIBUTE"
6464 # uid (login)
6565 _getattribute "$_ENTRY" "uid"
66 [ -z "$_ATTRIBUTE" ] && end_die "Error getting user attributes from LDAP (uid)"
66 [ -z "$_ATTRIBUTE" ] && end_die "Error getting user attribute from LDAP (uid)"
6767 _UID="$_ATTRIBUTE"
6868 # gidNumber
6969 _getattribute "$_ENTRY" "gidNumber"
70 [ -z "$_ATTRIBUTE" ] && end_die "Error getting user attributes from LDAP (gidNumber)"
70 [ -z "$_ATTRIBUTE" ] && end_die "Error getting user attribute from LDAP (gidNumber)"
7171 _PRIMARYGID="$_ATTRIBUTE"
7272
7373 case "$1" in