[25588] branches/dp2mp-move/base

source_changes at macosforge.org source_changes at macosforge.org
Fri May 25 07:01:44 PDT 2007


Revision: 25588
          http://trac.macosforge.org/projects/macports/changeset/25588
Author:   jmpp at macports.org
Date:     2007-05-25 07:01:44 -0700 (Fri, 25 May 2007)

Log Message:
-----------

Merging eridius' r25586: Use dscl instead of niutil and add support for realname key on addgroup.
Refs #11012

Modified Paths:
--------------
    branches/dp2mp-move/base/ChangeLog
    branches/dp2mp-move/base/doc/portfile.7
    branches/dp2mp-move/base/src/port1.0/portutil.tcl

Modified: branches/dp2mp-move/base/ChangeLog
===================================================================
--- branches/dp2mp-move/base/ChangeLog	2007-05-25 08:34:42 UTC (rev 25587)
+++ branches/dp2mp-move/base/ChangeLog	2007-05-25 14:01:44 UTC (rev 25588)
@@ -6,6 +6,9 @@
 
 (unreleased)
 
+    - Update adduser/addgroup to use dscl instead of niutil. Also add support
+      for realname key in addgroup (ticket #11012, eridius r25586).
+
     - Make a correction to port(1)'s determination of whether or not a port has
       been updated by making it compare ${version} and then ${revision} rather
       than a single comparison of the compound ${version}_${revision}; the

Modified: branches/dp2mp-move/base/doc/portfile.7
===================================================================
--- branches/dp2mp-move/base/doc/portfile.7	2007-05-25 08:34:42 UTC (rev 25587)
+++ branches/dp2mp-move/base/doc/portfile.7	2007-05-25 14:01:44 UTC (rev 25588)
@@ -1574,10 +1574,11 @@
 .Ar group
 .Op Cm gid Ns = Ns gid
 .Op Cm passwd Ns = Ns passwd
+.Op Cm realname Ns = Ns realname
 .Op Cm users Ns = Ns users
 .Xc
-Add a new local group to the system, with the specified gid, password
-and with a list users as members.
+Add a new local group to the system, with the specified gid, password,
+real name, and with a list users as members.
 .It Ic existsgroup Ar group
 Check if a local group exists and return the corresponding gid. This can be used
 with adduser:

Modified: branches/dp2mp-move/base/src/port1.0/portutil.tcl
===================================================================
--- branches/dp2mp-move/base/src/port1.0/portutil.tcl	2007-05-25 08:34:42 UTC (rev 25587)
+++ branches/dp2mp-move/base/src/port1.0/portutil.tcl	2007-05-25 14:01:44 UTC (rev 25588)
@@ -1646,7 +1646,7 @@
 
 proc adduser {name args} {
     global os.platform
-    set passwd {\*}
+    set passwd {*}
     set uid [nextuid]
     set gid [existsgroup nogroup]
     set realname ${name}
@@ -1654,59 +1654,59 @@
     set shell /dev/null
     
     foreach arg $args {
-	if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
-	    regsub -all " " ${val} "\\ " val
-	    set $key $val
-	}
+        if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
+            regsub -all " " ${val} "\\ " val
+            set $key $val
+        }
     }
     
     if {[existsuser ${name}] != 0 || [existsuser ${uid}] != 0} {
-	return
+        return
     }
     
-    if {${os.platform} == "darwin"} {
-	system "niutil -create . /users/${name}"
-	system "niutil -createprop . /users/${name} name ${name}"
-	system "niutil -createprop . /users/${name} passwd ${passwd}"
-	system "niutil -createprop . /users/${name} uid ${uid}"
-	system "niutil -createprop . /users/${name} gid ${gid}"
-	system "niutil -createprop . /users/${name} realname ${realname}"
-	system "niutil -createprop . /users/${name} home ${home}"
-	system "niutil -createprop . /users/${name} shell ${shell}"
+    if {${os.platform} eq "darwin"} {
+        exec dscl . -create /Users/${name} Password ${passwd}
+        exec dscl . -create /Users/${name} UniqueID ${uid}
+        exec dscl . -create /Users/${name} PrimaryGroupID ${gid}
+        exec dscl . -create /Users/${name} RealName ${realname}
+        exec dscl . -create /Users/${name} NFSHomeDirectory ${home}
+        exec dscl . -create /Users/${name} UserShell ${shell}
     } else {
-	# XXX adduser is only available for darwin, add more support here
-	ui_warn "WARNING: adduser is not implemented on ${os.platform}."
-	ui_warn "The requested user was not created."
+        # XXX adduser is only available for darwin, add more support here
+        ui_warn "WARNING: adduser is not implemented on ${os.platform}."
+        ui_warn "The requested user was not created."
     }
 }
 
 proc addgroup {name args} {
     global os.platform
     set gid [nextgid]
-    set passwd {\*}
+    set realname ${name}
+    set passwd {*}
     set users ""
     
     foreach arg $args {
-	if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
-	    regsub -all " " ${val} "\\ " val
-	    set $key $val
-	}
+        if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
+            regsub -all " " ${val} "\\ " val
+            set $key $val
+        }
     }
     
     if {[existsgroup ${name}] != 0 || [existsgroup ${gid}] != 0} {
-	return
+        return
     }
     
-    if {${os.platform} == "darwin"} {
-	system "niutil -create . /groups/${name}"
-	system "niutil -createprop . /groups/${name} name ${name}"
-	system "niutil -createprop . /groups/${name} gid ${gid}"
-	system "niutil -createprop . /groups/${name} passwd ${passwd}"
-	system "niutil -createprop . /groups/${name} users ${users}"
+    if {${os.platform} eq "darwin"} {
+        exec dscl . -create /Groups/${name} Password ${passwd}
+        exec dscl . -create /Groups/${name} RealName ${realname}
+        exec dscl . -create /Groups/${name} PrimaryGroupID ${gid}
+        if {${users} ne ""} {
+            exec dscl . -create /Groups/${name} GroupMembership ${users}
+        }
     } else {
-	# XXX addgroup is only available for darwin, add more support here
-	ui_warn "WARNING: addgroup is not implemented on ${os.platform}."
-	ui_warn "The requested group was not created."
+        # XXX addgroup is only available for darwin, add more support here
+        ui_warn "WARNING: addgroup is not implemented on ${os.platform}."
+        ui_warn "The requested group was not created."
     }
 }
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070525/bbc3dc25/attachment.html


More information about the macports-changes mailing list