Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Better user lookup
#1
I would suggest that you modify getUserID in common.php to retrieve whatever username is assigned uid:gid of 1000:1000 in /etc/passwd

Reasoning: According to the comment before the function definition, the assumption is that there will only be one user directory under /home and that will be the user id/name entered into the Raspberry Pi Imager. There is no guarantee that is always going to be the case and, if a second (or third or more) id created, that can break the local display xterm setup. Specifically, the wrong username can be entered in /lib/systemd/system/localdisplay.service, which will cause the local display to abend. What is true, however, is that the UID:GID for the account entered into the imager is ALWAYS going to be 1000:1000 and using that as the basis for fetching the username will ensure that the correct username is returned regardless of how many additional accounts the user creates.

Suggested replacement function:

function getUserID()
{
   $userID = sysCmd('grep 1000:1000 /etc/passwd | cut -d: -f1') ;

   if ( $userID != 'pi' )
   {
      $targetDir = sysCmd('grep 1000:1000 /etc/passwd | cut -d: -f6' ) ;

      // The /home/pi is created by the moode-player package install during in-place update.
      // If it exists, copy xinitrc script to the installation owners home directory and delete /home/pi
      if (file_exists('/home/pi/.xinitrc'))
      {
         sysCmd('cp /home/pi/.xinitrc $targetDir');
         sysCmd('rm -rf /home/pi/');
      }
   }

   return $userId;
}
Reply
#2
I can add to the TODO list to investigate but first help me understand what usage scenarios need additional user id's.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
I'm old school and I practice least privileged id access on all my servers. If I want to poke around without any fear of accidentally overwriting configuration files or generally munging up the entire install, I prefer to use an account that is guaranteed to not have write permissions to any of the configuration or data directories.

An alternative reason for it is simply to cut down on the number of questions from new users such as myself when they add a user (because if they can, they will) and do not have the expertise to track down the cause when things suddenly stop working. I did see a couple of posts regarding this when I first shot myself in the foot and I was able to track down the cause but a lot of people would not be able to do so and could end up abandoning the player altogether.
Reply
#4
I get that.

@TheOldPresbyope also mentioned using 1000:1000
https://moodeaudio.org/forum/showthread....8#pid63038

I'll add to the TODO list, and thanks for the code :-)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: