keeleysam / instadmg

Automatically exported from code.google.com/p/instadmg
0 stars 0 forks source link

createUser adds an extra newline to password hash #88

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure and deploy createUser.pkg
2. sudo ls -l /private/var/db/shadow/hash

What is the expected output? What do you see instead?
1240 byte hash is 1241 bytes for accounts created with createUser

What version of InstaDMG are you running? What revision number (this should
be the second line of your package log)?
r415

What OS are you running on (booted from)?
10.6.6

What OS are you installing?
10.6.6

Please provide any additional information below.
Quick fix:

Index: createUser.pkg/Contents/Resources/postflight
===================================================================
--- createUser.pkg/Contents/Resources/postflight    (revision 415)
+++ createUser.pkg/Contents/Resources/postflight    (working copy)
@@ -221,7 +221,7 @@
 fi 

 #create shadow hash file and set perms
-echo "$password_hash">"${TARGET_DIR}/var/db/shadow/hash/$genUID"
+echo -n "$password_hash">"${TARGET_DIR}/var/db/shadow/hash/$genUID"
 /bin/chmod 600 "${TARGET_DIR}/var/db/shadow/hash/$genUID"

 #if admin flag is set, then add user to admin group

Original issue reported on code.google.com by MagerV...@gmail.com on 4 Apr 2011 at 9:20

GoogleCodeExporter commented 9 years ago
Hey magervalp.
Greatly appreciated, I'll check this in during the next round of updates.  
Thanks, Allister

Original comment by allister...@gtempaccount.com on 5 Apr 2011 at 4:21

GoogleCodeExporter commented 9 years ago
Actually, I couldn't get your patch to work, it was sending the -n and 
whitespace into the beginning of the hash.  I used this line successfully 
instead:

`cat "${SCRIPT_DIR}/password_hash">"${TARGET_DIR}/var/db/shadow/hash/$genUID"`

Original comment by allister...@gtempaccount.com on 11 Apr 2011 at 1:17

GoogleCodeExporter commented 9 years ago
May I consider this issue closed, as per the fix included in r417?  
I should probably add the clearReg and AppleSetupDone commands into createUser 
as well... maybe next commit

Original comment by allister...@gtempaccount.com on 20 May 2011 at 2:12

GoogleCodeExporter commented 9 years ago
No, these do not belong in createUser. It is perfectly reasonable to add users 
to an image that you still want to have go through the first boot system. Plus, 
then lots of other first-run-setup things would also have to go in. And 
finally... you would not want to do this twice if you are setting up two users. 
That would just make things in the package database confused for no reason.

Original comment by kuehn.k...@gmail.com on 20 May 2011 at 2:41

GoogleCodeExporter commented 9 years ago
Well, the precedent/convention set by netRestore in SIU is it _IS_ of 
use/belongs:

##
CreateUserAccounts()
{
    local count="${#userFullName[*]}"
    if [ $count -gt 0 ]; then
        if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
            echo "Adding $count user account(s) to the image"
        fi
        for ((index=0; index<$count; index++)); do
            if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
                echo "Adding user ${userFullName[$index]}"
            fi
            #lay down user here
            AddLocalUser "${userFullName[$index]}" "${userUnixName[$index]}" "${userIsAdmin[$index]}" "${userPassHash[$index]}" "${userImagePath[$index]}" "${userLanguage[$index]}"
        done
        # "touch"
        /usr/bin/touch "${mountPoint}/private/var/db/.AppleSetupDone" 
        /usr/bin/touch "${mountPoint}/Library/Receipts/.SetupRegComplete"
    fi
}
##

But not as part of this repo if you don't think it belongs, I can build in 
iteration options(password hashes can be named after the $shortname so multiple 
can be found) and if clearReg = 1, touch SetupDone/ClearReg as part of the 
userdata file in my github One-Stop-LocalMCX repo instead.
And a generic firstboot, timezone-setting package for people to build 
upon(helping beginners understand how that can work and enabling them to add 
other common things like turning off firewire network settings, disabling 
airport, etc) would be another basic to provide IMO, I'll share mine soon.

Original comment by allister...@gtempaccount.com on 26 May 2011 at 1:56