Ignore:
Timestamp:
May 25, 2007, 8:10:01 AM (10 years ago)
Author:
eridius@…
Message:

Use dscl instead of niutil (Fixes #11012)
Add support for realname key on addgroup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r25285 r25586  
    16471647proc adduser {name args} {
    16481648    global os.platform
    1649     set passwd {\*}
     1649    set passwd {*}
    16501650    set uid [nextuid]
    16511651    set gid [existsgroup nogroup]
     
    16551655   
    16561656    foreach arg $args {
    1657         if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
    1658             regsub -all " " ${val} "\\ " val
    1659             set $key $val
    1660         }
     1657        if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
     1658            regsub -all " " ${val} "\\ " val
     1659            set $key $val
     1660        }
    16611661    }
    16621662   
    16631663    if {[existsuser ${name}] != 0 || [existsuser ${uid}] != 0} {
    1664         return
    1665     }
    1666    
    1667     if {${os.platform} == "darwin"} {
    1668         system "niutil -create . /users/${name}"
    1669         system "niutil -createprop . /users/${name} name ${name}"
    1670         system "niutil -createprop . /users/${name} passwd ${passwd}"
    1671         system "niutil -createprop . /users/${name} uid ${uid}"
    1672         system "niutil -createprop . /users/${name} gid ${gid}"
    1673         system "niutil -createprop . /users/${name} realname ${realname}"
    1674         system "niutil -createprop . /users/${name} home ${home}"
    1675         system "niutil -createprop . /users/${name} shell ${shell}"
     1664        return
     1665    }
     1666   
     1667    if {${os.platform} eq "darwin"} {
     1668        exec dscl . -create /Users/${name} Password ${passwd}
     1669        exec dscl . -create /Users/${name} UniqueID ${uid}
     1670        exec dscl . -create /Users/${name} PrimaryGroupID ${gid}
     1671        exec dscl . -create /Users/${name} RealName ${realname}
     1672        exec dscl . -create /Users/${name} NFSHomeDirectory ${home}
     1673        exec dscl . -create /Users/${name} UserShell ${shell}
    16761674    } else {
    1677         # XXX adduser is only available for darwin, add more support here
    1678         ui_warn "WARNING: adduser is not implemented on ${os.platform}."
    1679         ui_warn "The requested user was not created."
     1675        # XXX adduser is only available for darwin, add more support here
     1676        ui_warn "WARNING: adduser is not implemented on ${os.platform}."
     1677        ui_warn "The requested user was not created."
    16801678    }
    16811679}
     
    16841682    global os.platform
    16851683    set gid [nextgid]
    1686     set passwd {\*}
     1684    set realname ${name}
     1685    set passwd {*}
    16871686    set users ""
    16881687   
    16891688    foreach arg $args {
    1690         if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
    1691             regsub -all " " ${val} "\\ " val
    1692             set $key $val
    1693         }
     1689        if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
     1690            regsub -all " " ${val} "\\ " val
     1691            set $key $val
     1692        }
    16941693    }
    16951694   
    16961695    if {[existsgroup ${name}] != 0 || [existsgroup ${gid}] != 0} {
    1697         return
    1698     }
    1699    
    1700     if {${os.platform} == "darwin"} {
    1701         system "niutil -create . /groups/${name}"
    1702         system "niutil -createprop . /groups/${name} name ${name}"
    1703         system "niutil -createprop . /groups/${name} gid ${gid}"
    1704         system "niutil -createprop . /groups/${name} passwd ${passwd}"
    1705         system "niutil -createprop . /groups/${name} users ${users}"
     1696        return
     1697    }
     1698   
     1699    if {${os.platform} eq "darwin"} {
     1700        exec dscl . -create /Groups/${name} Password ${passwd}
     1701        exec dscl . -create /Groups/${name} RealName ${realname}
     1702        exec dscl . -create /Groups/${name} PrimaryGroupID ${gid}
     1703        if {${users} ne ""} {
     1704            exec dscl . -create /Groups/${name} GroupMembership ${users}
     1705        }
    17061706    } else {
    1707         # XXX addgroup is only available for darwin, add more support here
    1708         ui_warn "WARNING: addgroup is not implemented on ${os.platform}."
    1709         ui_warn "The requested group was not created."
     1707        # XXX addgroup is only available for darwin, add more support here
     1708        ui_warn "WARNING: addgroup is not implemented on ${os.platform}."
     1709        ui_warn "The requested group was not created."
    17101710    }
    17111711}
Note: See TracChangeset for help on using the changeset viewer.