Skip to content
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

future3 - allow custom username #2132

Merged

Conversation

AlvinSchiller
Copy link
Collaborator

@AlvinSchiller AlvinSchiller commented Dec 2, 2023

Allow custom usernames others then 'pi'

The docker setup has still some hardcoded references to the pi home. I didnt changes that so far.

@AlvinSchiller AlvinSchiller requested a review from pabera December 2, 2023 20:40
@s-martin s-martin added enhancement future3 Relates to future3 development labels Dec 2, 2023
@AlvinSchiller AlvinSchiller marked this pull request as ready for review December 2, 2023 22:27
Copy link
Collaborator

@pabera pabera left a comment

Choose a reason for hiding this comment

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

Thank you. Looks good so far. I had a few minor comments

CONTRIBUTING.md Outdated
@@ -63,7 +63,7 @@ For bug fixes and improvements just open an issue or PR as described below. If y
* By default this will get you to the `future3/main` branch. You will move to the `future3/develop` branch, do this:

~~~bash
cd /home/pi/RPi-Jukebox-RFID
cd /home/$USER/RPi-Jukebox-RFID
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we also use cd ~/RPi-Jukebox-RFID?
I wonder if this is sufficient. It seems we have avoided this notation in the past...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are a few places in the docs and comments that state to not use '~' .
In fact i dont know the problems that led to this statements.

Here it should be not a problem, but dont know for the config files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember in an old project we had the problem that ~ wouldn't resolve to the correct path under some circumstances, but unfortunately I don't remember the details anymore.

But if we tested it and it works I see no problem using it.

Copy link
Collaborator Author

@AlvinSchiller AlvinSchiller Dec 4, 2023

Choose a reason for hiding this comment

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

Maybe its a problem, if a service is run as root and not as user?
Do we still have those?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really, I'd say. We do everything within the user, even in Docker. Should be ok. But must be tested of course.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should check this and if it makes definition easier, but in another PR.
What do you think?

@@ -8,6 +8,6 @@ browser for now.
## Configuration

In `jukebox.yaml` (and all other config files): do not use relative paths with `~/some/dir`.
Always use entire explicit path, e.g. `/home/pi/some/dir`.
Always use relativ path from settingsfile '../../'
Copy link
Collaborator

Choose a reason for hiding this comment

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

My comment here would be similar to the one above. There is a also a context flaw here:

  1. In line 10, we say: "do not use relative paths"
  2. In line 11, we say: "Always use relativ path from" -> there is also a typo ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above.

  1. is says dont use relative paths with '~'. But it can be misleading. i rephrased it.

Comment on lines 50 to 53
# currently the user 'pi' is mandatory
# https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1785
_check_user() {
if [ "${CURRENT_USER}" != "pi" ]; then
echo
echo "ERROR: User must be 'pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
exit 2
fi

if [ "${HOME_PATH}" != "/home/pi" ]; then
echo
echo "ERROR: HomeDir must be '/home/pi'!"
echo " Other usernames are currently not supported."
echo " Please check the wiki for further information"
exit 2
fi

if [ ! -d "${HOME_PATH}" ]; then
echo
echo "ERROR: HomeDir ${HOME_PATH} does not exist."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this at all now? We can expect that there is a home directory available.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should be present, but doesn't harm to make sure ^^

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should remove it. It's a default expectation that a home directory exists. You also don't check if a kernel exists :-) We can anticipate this now and we only had this because we wanted to avoid people using custom usernames. since this is now resolved, we should remove the check. In 1 year from now, if we only look at this code we don't know anymore why this was added

Copy link
Collaborator

Choose a reason for hiding this comment

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

Less code is always better ;-)

Copy link
Collaborator Author

@AlvinSchiller AlvinSchiller Dec 4, 2023

Choose a reason for hiding this comment

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

removed.
The installation will already abort in the next step if the home_path is not present ^^

cd "${HOME_PATH}" || exit_on_error "ERROR: Changing to home dir failed."

@@ -1,5 +1,5 @@
# IMPORTANT:
# Do not use paths with '~/some/dir' - always use '/home/pi/some/dir'
# Do not use paths with '~/some/dir' - always use relativ path from settingsfile '../../'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo: "relative"

Comment on lines 31 to 32
TEST_USER_NAME: hans
TEST_USER_GROUP: wurst
TEST_USER_NAME: testuser
TEST_USER_GROUP: testusergroup
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a sad change 😄

@AlvinSchiller AlvinSchiller merged commit cf5aa6c into MiczFlor:future3/develop Dec 4, 2023
12 checks passed
@AlvinSchiller AlvinSchiller deleted the future3/feature/username branch December 4, 2023 22:23
AlvinSchiller added a commit to AlvinSchiller/RPi-Jukebox-RFID that referenced this pull request Dec 4, 2023
* removed hardcoded references to user "pi"

* removed check userNotPi

* change testuser in workflow and container

* updated docs

* updated comments and docs

* updated comments and docs

* remove extra home_path check

* changes testuser name and group
@s-martin s-martin linked an issue Dec 5, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement future3 Relates to future3 development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installation as different user (not user pi) 🚀 | Phniebox running as non root user
3 participants