소스 검색

Ticket #48285 - The dirsrv user/group should be created in rpm %pre, and ideally with fixed uid/gid

Description: Adding user dirsrv (uid 389) and group dirsrv (gid 389)
if they do not exist.  If the uid and the gid are in use, increase
one by one and find unused id for them.  If they exists, no change
is made.  The default user and group pair (nobody, nobody) is also
replaced with (dirsrv, dirsrv).

https://fedorahosted.org/389/ticket/48285

Reviewed by [email protected] (Thank you, William!)
Noriko Hosoi 10 년 전
부모
커밋
44d47d566a
2개의 변경된 파일23개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      configure.ac
  2. 21 0
      rpm/389-ds-base.spec.in

+ 2 - 2
configure.ac

@@ -328,8 +328,8 @@ configdir=/$PACKAGE_NAME/config
 schemadir=/$PACKAGE_NAME/schema
 schemadir=/$PACKAGE_NAME/schema
 
 
 # default user, group
 # default user, group
-defaultuser=nobody
-defaultgroup=nobody
+defaultuser=dirsrv
+defaultgroup=dirsrv
 
 
 if test -z "$with_tmpfiles_d" ; then
 if test -z "$with_tmpfiles_d" ; then
    if test -d $sysconfdir/tmpfiles.d ; then
    if test -d $sysconfdir/tmpfiles.d ; then

+ 21 - 0
rpm/389-ds-base.spec.in

@@ -274,6 +274,27 @@ if [ -n "$DEBUGPOSTTRANS" ] ; then
    output=$DEBUGPOSTTRANS
    output=$DEBUGPOSTTRANS
    output2=${DEBUGPOSTTRANS}.upgrade
    output2=${DEBUGPOSTTRANS}.upgrade
 fi
 fi
+
+has_dirsrv=`/usr/bin/egrep -i "^dirsrv\>" /etc/passwd` || :
+if [ "$has_dirsrv" = "" ]; then
+  dirsrv_uid=389
+    while [ "`getent passwd | awk -F: '{print $3}' | grep $dirsrv_uid`" != "" ]; do
+    dirsrv_uid=`expr $dirsrv_uid + 1`
+  done
+    echo "User dirsrv does not exist, create it with uid %dirsrv_uid." >> $output 2>&1 || :
+  /usr/sbin/useradd -c "389-ds-base" -u $dirsrv_uid \
+      -s /sbin/nologin -r -d /usr/share/dirsrv dirsrv 2> /dev/null || :
+  fi
+  has_dirsrv=`/usr/bin/egrep -i "^dirsrv\>" /etc/group` || :
+  if [ "$has_dirsrv" = "" ]; then
+    dirsrv_gid=389
+  while [ "`getent group | grep $dirsrv_gid`" != "" ]; do
+      dirsrv_gid=`expr $dirsrv_gid + 1`
+    done
+  echo "Group dirsrv does not exist, create it with uid %dirsrv_gid." >> $output 2>&1 || :
+    /usr/sbin/groupadd -g $dirsrv_gid -r dirsrv 2> /dev/null || :
+fi
+
 echo looking for instances in %{_sysconfdir}/%{pkgname} > $output 2>&1 || :
 echo looking for instances in %{_sysconfdir}/%{pkgname} > $output 2>&1 || :
 instbase="%{_sysconfdir}/%{pkgname}"
 instbase="%{_sysconfdir}/%{pkgname}"
 for dir in $instbase/slapd-* ; do
 for dir in $instbase/slapd-* ; do