Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1198)

Side by Side Diff: src/scripts/customize_rootfs.sh

Issue 501132: Add the default user to some groups (audio, video). (Closed)
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Script to customize the root file system after packages have been installed. 7 # Script to customize the root file system after packages have been installed.
8 # 8 #
9 # NOTE: This script should be called by build_image.sh. Do not run this 9 # NOTE: This script should be called by build_image.sh. Do not run this
10 # on your own unless you know what you are doing. 10 # on your own unless you know what you are doing.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 CRYPTED_PASSWD=$(cat $CRYPTED_PASSWD_FILE) 53 CRYPTED_PASSWD=$(cat $CRYPTED_PASSWD_FILE)
54 else 54 else
55 # Use a random password. unix_md5_crypt will generate a random salt. 55 # Use a random password. unix_md5_crypt will generate a random salt.
56 echo "Using random password." 56 echo "Using random password."
57 PASSWORD="$(base64 /dev/urandom | head -1)" 57 PASSWORD="$(base64 /dev/urandom | head -1)"
58 CRYPTED_PASSWD="$(echo "$PASSWORD" | openssl passwd -1 -stdin)" 58 CRYPTED_PASSWD="$(echo "$PASSWORD" | openssl passwd -1 -stdin)"
59 PASSWORD="gone now" 59 PASSWORD="gone now"
60 fi 60 fi
61 61
62 # Set up a default user and add to sudo and the required groups. 62 # Set up a default user and add to sudo and the required groups.
63 USERNAME="chronos" 63 ADD_USER="chronos"
64 ADD_GROUPS="audio video"
64 SHELL="/bin/sh" 65 SHELL="/bin/sh"
65 if [[ -x "${ROOT_FS_DIR}/bin/bash" ]] ; then 66 if [[ -x "${ROOT_FS_DIR}/bin/bash" ]] ; then
66 SHELL="/bin/bash" 67 SHELL="/bin/bash"
67 fi 68 fi
68 echo "${USERNAME}:x:1000:1000:${FULLNAME}:/home/${USERNAME}/:${SHELL}" | \ 69 echo "${ADD_USER}:x:1000:1000:${FULLNAME}:/home/${ADD_USER}/:${SHELL}" | \
69 sudo dd of="${ROOT_FS_DIR}/etc/passwd" conv=notrunc oflag=append 70 sudo dd of="${ROOT_FS_DIR}/etc/passwd" conv=notrunc oflag=append
70 echo "${USERNAME}:${CRYPTED_PASSWD}:14500:0:99999::::" | \ 71 echo "${ADD_USER}:${CRYPTED_PASSWD}:14500:0:99999::::" | \
71 sudo dd of="${ROOT_FS_DIR}/etc/shadow" conv=notrunc oflag=append 72 sudo dd of="${ROOT_FS_DIR}/etc/shadow" conv=notrunc oflag=append
72 echo "${USERNAME}:x:1000:" | \ 73 echo "${ADD_USER}:x:1000:" | \
73 sudo dd of="${ROOT_FS_DIR}/etc/group" conv=notrunc oflag=append 74 sudo dd of="${ROOT_FS_DIR}/etc/group" conv=notrunc oflag=append
74 # TODO: Add USERNAME to adm,dialout,cdrom,floppy,audio,dip,video groups? 75 for i in $ADD_GROUPS; do
75 sudo mkdir -p "${ROOT_FS_DIR}/home/${USERNAME}" 76 sudo sed -i "s/^\($i:x:[0-9]*:.*\)/\1,${ADD_USER}/g" \
76 sudo chown 1000.1000 "${ROOT_FS_DIR}/home/${USERNAME}" 77 "${ROOT_FS_DIR}"/etc/group
78 done
79
80 sudo mkdir -p "${ROOT_FS_DIR}/home/${ADD_USER}"
81 sudo chown 1000.1000 "${ROOT_FS_DIR}/home/${ADD_USER}"
77 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/sudoers" conv=notrunc oflag=append 82 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/sudoers" conv=notrunc oflag=append
78 %adm ALL=(ALL) ALL 83 %adm ALL=(ALL) ALL
79 $USERNAME ALL=(ALL) ALL 84 $ADD_USER ALL=(ALL) ALL
80 EOF 85 EOF
81 sudo chmod 0440 "${ROOT_FS_DIR}/etc/sudoers" 86 sudo chmod 0440 "${ROOT_FS_DIR}/etc/sudoers"
82 87
83 # Set CHROMEOS_VERSION_DESCRIPTION here (uses vars set in chromeos_version.sh) 88 # Set CHROMEOS_VERSION_DESCRIPTION here (uses vars set in chromeos_version.sh)
84 # Was removed from chromeos_version.sh which can also be run outside of chroot 89 # Was removed from chromeos_version.sh which can also be run outside of chroot
85 # where CHROMEOS_REVISION is set 90 # where CHROMEOS_REVISION is set
86 # We have to set (in build_image.sh) and use REAL_USER due to many nested 91 # We have to set (in build_image.sh) and use REAL_USER due to many nested
87 # chroots which lose $USER state. 92 # chroots which lose $USER state.
88 . "${SCRIPTS_DIR}/chromeos_version.sh" 93 . "${SCRIPTS_DIR}/chromeos_version.sh"
89 if [ ${CHROMEOS_OFFICIAL:-0} = 1 ]; then 94 if [ ${CHROMEOS_OFFICIAL:-0} = 1 ]; then
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/network/interfaces" 246 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/network/interfaces"
242 auto lo 247 auto lo
243 iface lo inet loopback 248 iface lo inet loopback
244 EOF 249 EOF
245 250
246 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/resolv.conf" 251 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/resolv.conf"
247 # Use the connman dns proxy. 252 # Use the connman dns proxy.
248 nameserver 127.0.0.1 253 nameserver 127.0.0.1
249 EOF 254 EOF
250 sudo chmod a-wx "${ROOT_FS_DIR}/etc/resolv.conf" 255 sudo chmod a-wx "${ROOT_FS_DIR}/etc/resolv.conf"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698