The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Messages In This Thread
Better user lookup - by Blytsplyk - 04-16-2025, 08:57 PM
RE: Better user lookup - by Tim Curtis - 04-16-2025, 09:05 PM
RE: Better user lookup - by Blytsplyk - 04-16-2025, 09:20 PM
RE: Better user lookup - by Tim Curtis - 04-16-2025, 09:33 PM

Forum Jump: