1 Index: ldapscripts-2.0.8/sbin/ldapaddsudo
2 ===================================================================
4 +++ ldapscripts-2.0.8/sbin/ldapaddsudo
8 +# ldapaddsudo : adds a sudoRole to LDAP
10 +# Copyright (C) 2005 Ganaël LAPLANCHE - Linagora
11 +# Copyright (C) 2006-2013 Ganaël LAPLANCHE
12 +# Copyright (c) 2014 Wind River Systems, Inc.
14 +# This program is free software; you can redistribute it and/or
15 +# modify it under the terms of the GNU General Public License
16 +# as published by the Free Software Foundation; either version 2
17 +# of the License, or (at your option) any later version.
19 +# This program is distributed in the hope that it will be useful,
20 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
21 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 +# GNU General Public License for more details.
24 +# You should have received a copy of the GNU General Public License
25 +# along with this program; if not, write to the Free Software
26 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
29 +if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]
31 + echo "Usage : $0 <username>"
35 +# Source runtime file
36 +_RUNTIMEFILE="/usr/lib/ldapscripts/runtime"
39 +# Username = first argument
42 +# Use template if necessary
43 +if [ -n "$STEMPLATE" ] && [ -r "$STEMPLATE" ]
45 + _getldif="cat $STEMPLATE"
47 + _getldif="_extractldif 2"
50 +# Add sudo entry to LDAP
51 +$_getldif | _filterldif | _askattrs | _utf8encode | _ldapadd
53 +[ $? -eq 0 ] || end_die "Error adding user $_USER to LDAP"
54 +echo_log "Successfully added sudo access for user $_USER to LDAP"
58 +# Ldif template ##################################
59 +##dn: cn=<user>,ou=SUDOers,<usuffix>,<suffix>
61 +##objectClass: sudoRole
67 +###sudoOrder: <default: 0, if multiple entries match, this entry with the highest sudoOrder is used>
68 +###sudoOption: <specify other sudo specific attributes here>
69 Index: ldapscripts-2.0.8/sbin/ldapmodifyuser
70 ===================================================================
71 --- ldapscripts-2.0.8.orig/sbin/ldapmodifyuser
72 +++ ldapscripts-2.0.8/sbin/ldapmodifyuser
74 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
77 -if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]
78 +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || \
79 + [[ "$2" != "add" && "$2" != "replace" && "$2" != "delete" ]] || \
82 - echo "Usage : $0 <username | uid>"
83 + echo "Usage : $0 <username | uid> [<add | replace | delete> <field> <value>]"
87 @@ -33,21 +35,48 @@ _RUNTIMEFILE="/usr/lib/ldapscripts/runti
88 _findentry "$USUFFIX,$SUFFIX" "(&(objectClass=posixAccount)(|(uid=$1)(uidNumber=$1)))"
89 [ -z "$_ENTRY" ] && end_die "User $1 not found in LDAP"
91 -# Allocate and create temp file
93 -echo "dn: $_ENTRY" > "$_TMPFILE" || end_die "Error writing to temporary file $_TMPFILE"
96 -echo "# About to modify the following entry :"
97 -_ldapsearch "$_ENTRY"
100 -echo "# Enter your modifications here, end with CTRL-D."
102 -cat >> "$_TMPFILE" || end_die "Error writing to temporary file $_TMPFILE"
103 +# Username = first argument
108 + # Allocate and create temp file
110 + echo "dn: $_ENTRY" > "$_TMPFILE" || end_die "Error writing to temporary file $_TMPFILE"
113 + echo "# About to modify the following entry :"
114 + _ldapsearch "$_ENTRY"
117 + echo "# Enter your modifications here, end with CTRL-D."
119 + cat >> "$_TMPFILE" || end_die "Error writing to temporary file $_TMPFILE"
121 + # Send modifications
122 + cat "$_TMPFILE" | _utf8encode | _ldapmodify
124 + # Action = second argument
127 + # Field = third argument
130 + # Value = fourth argument
133 + # Use template if necessary
134 + if [ -n "$UMTEMPLATE" ] && [ -r "$UMTEMPLATE" ]
136 + _getldif="cat $UMTEMPLATE"
138 + _getldif="_extractldif 2"
141 + # Modify user in LDAP
142 + $_getldif | _filterldif | _utf8encode | _ldapmodify
145 -# Send modifications
146 -cat "$_TMPFILE" | _utf8encode | _ldapmodify
150 @@ -55,3 +84,9 @@ then
153 end_ok "Successfully modified user entry $_ENTRY in LDAP"
155 +# Ldif template ##################################
156 +##dn: uid=<user>,<usuffix>,<suffix>
157 +##changeType: modify
160 Index: ldapscripts-2.0.8/lib/runtime
161 ===================================================================
162 --- ldapscripts-2.0.8.orig/lib/runtime
163 +++ ldapscripts-2.0.8/lib/runtime
164 @@ -344,6 +344,9 @@ s|<msuffix>|$MSUFFIX|g
165 s|<_msuffix>|$_MSUFFIX|g
166 s|<gsuffix>|$GSUFFIX|g
167 s|<_gsuffix>|$_GSUFFIX|g
168 +s|<action>|$_ACTION|g
174 Index: ldapscripts-2.0.8/Makefile
175 ===================================================================
176 --- ldapscripts-2.0.8.orig/Makefile
177 +++ ldapscripts-2.0.8/Makefile
178 @@ -37,11 +37,11 @@ LIBDIR = $(PREFIX)/lib/$(NAME)
180 ETCFILE = ldapscripts.conf
181 PWDFILE = ldapscripts.passwd
182 -SBINFILES = ldapdeletemachine ldapmodifygroup ldapsetpasswd lsldap ldapadduser \
183 +SBINFILES = ldapdeletemachine ldapmodifygroup ldapsetpasswd lsldap ldapadduser ldapaddsudo \
184 ldapdeleteuser ldapsetprimarygroup ldapfinger ldapid ldapgid ldapmodifymachine \
185 ldaprenamegroup ldapaddgroup ldapaddusertogroup ldapdeleteuserfromgroup \
186 ldapinit ldapmodifyuser ldaprenamemachine ldapaddmachine ldapdeletegroup \
188 + ldaprenameuser ldapmodifysudo
189 MAN1FILES = ldapdeletemachine.1 ldapmodifymachine.1 ldaprenamemachine.1 ldapadduser.1 \
190 ldapdeleteuserfromgroup.1 ldapfinger.1 ldapid.1 ldapgid.1 ldapmodifyuser.1 lsldap.1 \
191 ldapaddusertogroup.1 ldaprenameuser.1 ldapinit.1 ldapsetpasswd.1 ldapaddgroup.1 \
192 Index: ldapscripts-2.0.8/sbin/ldapmodifysudo
193 ===================================================================
195 +++ ldapscripts-2.0.8/sbin/ldapmodifysudo
199 +# ldapmodifyuser : modifies a sudo entry in an LDAP directory
201 +# Copyright (C) 2007-2013 Ganaël LAPLANCHE
202 +# Copyright (C) 2014 Stephen Crooks
204 +# This program is free software; you can redistribute it and/or
205 +# modify it under the terms of the GNU General Public License
206 +# as published by the Free Software Foundation; either version 2
207 +# of the License, or (at your option) any later version.
209 +# This program is distributed in the hope that it will be useful,
210 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
211 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212 +# GNU General Public License for more details.
214 +# You should have received a copy of the GNU General Public License
215 +# along with this program; if not, write to the Free Software
216 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
219 +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || \
220 + [[ "$2" != "add" && "$2" != "replace" && "$2" != "delete" ]] || \
223 + echo "Usage : $0 <username | uid> [<add | replace | delete> <field> <value>]"
227 +# Source runtime file
228 +_RUNTIMEFILE="/usr/lib/ldapscripts/runtime"
231 +# Find username : $1 must exist in LDAP !
232 +_findentry "$SUFFIX" "(&(objectClass=sudoRole)(|(cn=$1)(sudoUser=$1)))"
233 +[ -z "$_ENTRY" ] && end_die "Sudo user $1 not found in LDAP"
235 +# Username = first argument
240 + # Allocate and create temp file
242 + echo "dn: $_ENTRY" > "$_TMPFILE" || end_die "Error writing to temporary file $_TMPFILE"
245 + echo "# About to modify the following entry :"
246 + _ldapsearch "$_ENTRY"
249 + echo "# Enter your modifications here, end with CTRL-D."
251 + cat >> "$_TMPFILE" || end_die "Error writing to temporary file $_TMPFILE"
253 + # Send modifications
254 + cat "$_TMPFILE" | _utf8encode | _ldapmodify
256 + # Action = second argument
259 + # Field = third argument
262 + # Value = fourth argument
265 + # Use template if necessary
266 + if [ -n "$SMTEMPLATE" ] && [ -r "$SMTEMPLATE" ]
268 + _getldif="cat $SMTEMPLATE"
270 + _getldif="_extractldif 2"
273 + # Modify user in LDAP
274 + $_getldif | _filterldif | _utf8encode | _ldapmodify
280 + end_die "Error modifying sudo entry $_ENTRY in LDAP"
283 +end_ok "Successfully modified sudo entry $_ENTRY in LDAP"
285 +# Ldif template ##################################
286 +##dn: cn=<user>,ou=SUDOers,<suffix>
287 +##changeType: modify