Skip to content

Added JPEGPhoto and createhomedir #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Added JPEGPhoto and createhomedir #14

wants to merge 3 commits into from

Conversation

gniemetz
Copy link

My first try to build a "real" python program, so please be patient :)

I've added the support for creating JPEGPhoto, also added support to create the home directory

Thanks you!

best regards
Gerd

@@ -36,16 +35,20 @@ def main():
required_user_options = optparse.OptionGroup(
parser, 'Required User Options')
required_user_options.add_option(
'--name', '-n', help='User shortname. REQUIRED.')
'--name', '-n',
help='User shortname. REQUIRED.')
required_user_options.add_option(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've made a bunch of changes unrelated to your core changes. This makes reviewing your changes harder.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry about that, thought it would be easier to read

createuserpkg Outdated
@@ -119,7 +135,10 @@ def main():
user_data['shell'] = options.shell
if options.hidden:
user_data['IsHidden'] = u'YES'

if options.picture:
from locallibs import imageutil
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imports really belong at the top of a Python file unless you have a really good reason to do them conditionally.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought i only import it if there is a image as argument, but i will put it on top

image_path,
temp_image)
try:
subprocess.call(cmd, shell=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use shell=True with subprocess. Properly format your command arguments into a list and use the command list with subprocess.call.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

@@ -88,6 +89,9 @@
/usr/bin/killall DirectoryService 2>/dev/null || /usr/bin/killall opendirectoryd 2>/dev/null
"""

PI_CREATEHOMEDIR = """
/usr/sbin/createhomedir -c
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using createhomedir will only work when a package is installed to the current boot volume. All the other options for pycreateuserpkg work no matter if the package target is the current boot volume or an alternate volume (as when installing into an AutoDMG image, or via a Imagr or DeployStudio or Bootstrappr workflow). I'm hesitant to merge a feature that works only sometimes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the latest 10.13.4 beta 4 there is also a new behavior to createmobileaccount that prompts in the cli run for an admin account to set the SecureToken. There is a -D option to suppress it. There should be some logic to detect the OS and act accordingly.

-Eric

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createmobileaccount and createhomedir are different tools; I don't know if there are similar new issues in 10.13.4 that would affect createhomedir.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put in into the if block, under the killall statements

Copy link
Owner

@gregneagle gregneagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See in-line comments.

- Imports of modules on top
- Changed to subprocess call
- Put the createhomedir into the if-block
@@ -88,6 +88,9 @@
/usr/bin/killall DirectoryService 2>/dev/null || /usr/bin/killall opendirectoryd 2>/dev/null
"""

PI_CREATEHOMEDIR = """
/usr/sbin/createhomedir -c
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you've addressed my issue with createhomedir not working for anything other than installs to /.
I think the postinstall script bit needs to test $3 and do the right thing, and I think the overall createuserpkg tool needs to warn people in the help output that this option works only in some scenarios; etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add the createhomedir command to the pi_live_actions, so it gets written into the if [ "$3" == "/" ] block. Additionally i will add a notice to the help text that says that it only work an a boot volume.
Would that be ok?
Thanks again
Gerd

@gniemetz
Copy link
Author

Have you had time to look at my latest pull request

Thanks in advance
regards
Gerd

@gregneagle
Copy link
Owner

Not yet, no.

@gregneagle
Copy link
Owner

Sorry, coming back to this now after a billion-year break; did you want to still work on merging this?

thehilll pushed a commit to thehilll/pycreateuserpkg that referenced this pull request Jun 6, 2019
--createhome creates the user's home directory and is largely based on the work and discussion in gregneagle#14

Changes for this option are to the OptionParser and creation of pkg_data in createuserpkg, make_config_file in userpkg.py and the postinstall script

The postinsstall script now checks for this option and if found runs:  /usr/sbin/createhomedir -c -u $USERNAME

--key will add the user's public key to ~/.ssh/authorized_keys.  Specifying --key implies --createhome.

Changes for this option are in the same locations as --createhome

The postinstall script will add the key to the user's authorized_keys file, creating it (and ~/.ssh) if it doesn't exist.  It will also set permissions on the files.  These commands are run as the user in order to expand ~ and pick up the user's GID when the files are created.  This seems to require the use of eval which means you need to trust the content of the --key variable.  If there is a safer way to do this that would be a good change.
@gregneagle gregneagle closed this Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants