8 Replies Latest reply on Jun 1, 2021 12:55 PM by gonewtinwind

    how to write a system service to auto startup chromium on wayland with non-root user?

    gonewtinwind

      Hi Joshua  & all

       

      I use the below system service can auto startup chromium on maaxboard wayland with root user, but it's not safe with root user, so I need to startup with non-root user.

      I tried to modify it somewhere, but not work.

      any help?

       

      my service ,you can see it's root user with --no-sandbox option :

      /etc/systemd/system/chromium.service

      ----

       

      Description=launch chromium

       

      [Service]

      User=root

      Environment=DISPLAY=:0

      Environment=XDG_RUNTIME_DIR="/run/user/0"

      Type=oneshot

      ExecStart=/bin/sleep 15

      ExecStart=/usr/bin/chromium --no-sandbox --disable-infobars --user-data-dir=/tmp/chromium --gpu-no-context-lost --enable-gpu-rasterization --start-fullscreen --kiosk --no-first-run --incognito http://localhost:3300/rpi.html > /dev/null 2>&1 &

       

      [Install]

      WantedBy=multi-user.target

       

      ref:can not auto startup chromium(chromium-ozone-wayland)

        • Re: how to write a system service to auto startup chromium on wayland with non-root user?
          jafoste4

          Hi Peter,

           

          Did you have success in finding a solution to this?

           

          Here is our reccomendation

          "

          It could be specified one user in system service , For example, let user ‘avnet’ start this service, then modify the property:

          /etc/systemd/system/chromium.service

          [Service]

          User=avnet

           

          Another method is to delete the property ‘’ User=’’ , then any user could use the service.

          "

           

          Thanks,
          Josh

          1 of 1 people found this helpful
            • Re: how to write a system service to auto startup chromium on wayland with non-root user?
              gonewtinwind

              Hi Josh,

              no work!

               

              debug

               

               

              systemctl status chromium.service

              * chromium.service - launch chromium

                 Loaded: loaded (/etc/systemd/system/chromium.service; enabled; vendor preset>

                 Active: failed (Result: signal) since Tue 2021-05-25 18:47:53 UTC; 2min 26s >

                Process: 832 ExecStart=/bin/sleep 15 (code=exited, status=0/SUCCESS)

                Process: 833 ExecStart=/usr/bin/chromium --user-data-dir=/tmp/chromium --gpu->

              Main PID: 833 (code=killed, signal=TRAP)

               

               

              May 25 18:47:37 maaxboard systemd[1]: Starting launch chromium...

              May 25 18:47:52 maaxboard chromium[833]: [833:833:0525/184752.979981:ERROR:wayl>

              May 25 18:47:52 maaxboard chromium[833]: [833:833:0525/184752.980050:FATAL:ozon>

              May 25 18:47:53 maaxboard systemd[1]: chromium.service: Main process exited, co>

              May 25 18:47:53 maaxboard systemd[1]: chromium.service: Failed with result 'sig>

              May 25 18:47:53 maaxboard systemd[1]: Failed to start launch chromium.

               

              both following services:

               

              1

               

              Description=launch chromium

               

              [Service]

              User=myuser

              Environment=DISPLAY=:0

              Environment=XDG_RUNTIME_DIR="/run/user/0"

              Type=oneshot

              ExecStart=/bin/sleep 15

              ExecStart=/usr/bin/chromium  --user-data-dir=/tmp/chromium --gpu-no-context-lost --enable-gpu-rasterization --start-fullscreen --kiosk --no-first-run --incognito http://localhost:3300/rpi.html > /dev/null 2>&1 &

               

              [Install]

              WantedBy=multi-user.target

               

               

              2

               

              Description=launch chromium

               

              [Service]

              User=myuser

              Environment=DISPLAY=:0

              Environment=XDG_RUNTIME_DIR="/run/user/0"

              Type=oneshot

              ExecStart=/bin/sleep 15

              ExecStart=/usr/bin/sudo -u myuser /usr/bin/chromium  --user-data-dir=/tmp/chromium --gpu-no-context-lost --enable-gpu-rasterization --start-fullscreen --kiosk --no-first-run --incognito http://localhost:3300/rpi.html > /dev/null 2>&1 &

               

              [Install]

              WantedBy=multi-user.target

                • Re: how to write a system service to auto startup chromium on wayland with non-root user?
                  gonewtinwind

                  I posted NXP too, but no solutions.

                  I tried to research online. but only old solutions for rc(old skills worked well before) not systemd.

                   

                  https://community.nxp.com/t5/i-MX-Processors/how-to-write-a-system-service-to-auto-startup-chromium-on/m-p/1275666#M1739…

                  any suggestions?

                    • Re: how to write a system service to auto startup chromium on wayland with non-root user?
                      jafoste4

                      Hi Peter,

                       

                      This should solve your problem.

                       

                      Refer to the following steps to solve this problem:

                      1  start the weston desktop on maaxboard with ‘avnet’ user. (Refer to the guide in PDF form below for detailed example)

                      2  create a service file and enable this service to automatically start Google Chrome

                         maaxboard:~# vi /etc/systemd/system/chromium.service

                      [Unit]

                      Description=chromium Browser

                      After=weston.service

                       

                      [Service]

                      User=avnet

                      Environment=DISPLAY=:0

                      Environment=XDG_RUNTIME_DIR="/run/user/1000"

                      Type=oneshot

                      ExecStart=/usr/bin/chromium --start-fullscreen > /dev/null 2>&1 &

                       

                      [Install]

                      WantedBy=multi-user.target

                         maaxboard:~# sudo systemctl daemon-reload

                         maaxboard:~# systemctl enable chromium.service

                       

                      Note: in the chromium.service file , the number 1000 is the user's id.

                      Use the command “id avnet” to get the user's id value

                       

                      3  reboot the system.

                       

                      Detailed guide see document - https://avtinc.sharepoint.com/:b:/t/ET-Downloads/EQCw2IF8l89Jo3yJokpDgHABeQbHIp2qwwOVyN759U4odg?e=ePHugh

                       

                      Thx,

                      Josh

                      1 of 1 people found this helpful
                        • Re: how to write a system service to auto startup chromium on wayland with non-root user?
                          gonewtinwind

                          hi Josh,

                          Thank you very much.

                          did you test it on your maaxboard(yocto-zeus)? I followed your guide, but it still does not work.

                           

                          debug info:

                           

                          systemctl start chromium.service

                          [   88.067474] audit: type=1701 audit(1622567912.343:5): auid=4294967295 uid=1001 gid=1002 ses=4294967295 pid=831 comm="chromium-bin" exe="/usr/lib/chromium/chromium-bin" sig=5 res=1

                          [   88.083553] audit: type=1701 audit(1622567912.351:6): auid=4294967295 uid=1001 gid=1002 ses=4294967295 pid=819 comm="chromium-bin" exe="/usr/lib/chromium/chromium-bin" sig=5 res=1

                          Job for chromium.service failed because a fatal signal was delivered to the control process.

                          See "systemctl status chromium.service" and "journalctl -xe" for details.

                          -sh-5.0# systemctl status chromium.service

                          * chromium.service - chromium Browser

                             Loaded: loaded (/etc/systemd/system/chromium.service; enabled; vendor preset>

                             Active: failed (Result: signal) since Tue 2021-06-01 17:18:32 UTC; 7s ago

                            Process: 819 ExecStart=/usr/bin/chromium --start-fullscreen > /dev/null 2>&1 >

                          Main PID: 819 (code=killed, signal=TRAP)

                           

                           

                          Jun 01 17:18:32 maaxboard systemd[1]: Starting chromium Browser...

                          Jun 01 17:18:32 maaxboard systemd[1]: chromium.service: Main process exited, co>

                          Jun 01 17:18:32 maaxboard systemd[1]: chromium.service: Failed with result 'sig>

                          Jun 01 17:18:32 maaxboard systemd[1]: Failed to start chromium Browser.

                          lines 1-10/10 (END)

                            • Re: how to write a system service to auto startup chromium on wayland with non-root user?
                              jafoste4

                              Hi Peter,


                              I will verify the OS used.

                              Can you share similiar screen captures as shown in the user guide provided to make sure we are on the same page?

                               

                              Thx,
                              Josh

                                • Re: how to write a system service to auto startup chromium on wayland with non-root user?
                                  gonewtinwind

                                  my commands:

                                  NXP i.MX Release Distro 5.4-zeus maaxboard ttymxc0

                                   

                                   

                                  maaxboard login: [   22.879528] Atheros 8035 ethernet 30be0000.ethernet-1:04: attached PHY driver [Atheros 8035 ethernet] (mii_bus:phy_addr=30be0000.ethernet-1:04, irq=POLL)

                                  [   25.954678] fec 30be0000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx

                                  [   25.962474] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

                                  [   25.988602] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.1: link becomes ready

                                  [   26.003080] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.2: link becomes ready

                                  root

                                  Password:

                                  Last login: Tue Jun  1 17:29:08 UTC 2021 on tty7

                                  -sh-5.0# useradd avnet

                                  -sh-5.0# passwd avnet                                                                                                                                                                         

                                  New password:

                                  Retype new password: [   67.986464] audit: type=1006 audit(1622568601.259:3): pid=783 uid=0 old-auid=4294967295 auid=0 tty=(none) old-ses=4294967295 ses=2 res=1

                                   

                                   

                                  passwd: password updated successfully

                                  -sh-5.0# usermod -aG video avnet

                                  -sh-5.0# groups avnet

                                  video avnet

                                   

                                   

                                  id avnet

                                  uid=1001(avnet) gid=1002(avnet) groups=1002(avnet),44(video)

                                  -sh-5.0# cat /etc/systemd/system/chromium.service                                                                                                                                             

                                  [Unit]

                                   

                                   

                                  Description=chromium Browser

                                   

                                   

                                  After=weston.service

                                   

                                   

                                   

                                   

                                   

                                  [Service]

                                   

                                   

                                  User=avnet

                                   

                                   

                                  Environment=DISPLAY=:0

                                   

                                   

                                  Environment=XDG_RUNTIME_DIR="/run/user/1001"

                                   

                                   

                                  Type=oneshot

                                   

                                   

                                  ExecStart=/usr/bin/chromium --start-fullscreen > /dev/null 2>&1 &

                                   

                                   

                                   

                                   

                                   

                                  [Install]

                                   

                                   

                                  WantedBy=multi-user.target

                                   

                                   

                                   

                                   

                                   

                                   

                                  sudo systemctl daemon-reload

                                  (

                                  [  361.369813] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.384935] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.400019] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.415015] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.430032] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.445022] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.460009] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.474984] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.489958] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.504923] systemd-fstab-generator[803]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [  361.521806] printk: systemd-fstab-g: 15 output lines suppressed due to ratelimiting

                                  systemctl enable chromium.service

                                  Created symlink /etc/systemd/system/multi-user.target.wants/chromium.service -> /etc/systemd/system/chromium.service.                      (see here: the link generated, the following errors is not for it)

                                  [   94.334139] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.349296] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.364402] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.364491] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.364577] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.364661] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.364750] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.439157] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.454146] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.469121] systemd-fstab-generator[805]: Failed to create unit file /run/systemd/generator/run-media-sda1.mount, as it already exists. Duplicate entry in /etc/fstab?

                                  [   94.485944] printk: systemd-fstab-g: 15 output lines suppressed due to ratelimiting

                                   

                                   

                                  after reboot or power off/on:

                                   

                                   

                                   

                                   

                                  systemctl start chromium.service

                                  [   66.891113] audit: type=1701 audit(1622569050.163:4): auid=4294967295 uid=1001 gid=1002 ses=4294967295 pid=802 comm="chromium-bin" exe="/usr/lib/chromium/chromium-bin" sig=5 res=1

                                  Job for chromium.service failed because a fatal signal was delivered to the control process.

                                  See "systemctl status chromium.service" and "journalctl -xe" for details.

                                  -sh-5.0# systemctl status chromium.service

                                  * chromium.service - chromium Browser

                                     Loaded: loaded (/etc/systemd/system/chromium.service; enabled; vendor preset>

                                     Active: failed (Result: signal) since Tue 2021-06-01 17:37:30 UTC; 8s ago

                                    Process: 802 ExecStart=/usr/bin/chromium --start-fullscreen > /dev/null 2>&1 >

                                  Main PID: 802 (code=killed, signal=TRAP)

                                   

                                   

                                  Jun 01 17:37:29 maaxboard systemd[1]: Starting chromium Browser...

                                  Jun 01 17:37:30 maaxboard chromium[802]: [802:802:0601/173730.165212:ERROR:wayl>

                                  Jun 01 17:37:30 maaxboard chromium[802]: [802:802:0601/173730.165287:FATAL:ozon>

                                  Jun 01 17:37:30 maaxboard systemd[1]: chromium.service: Main process exited, co>

                                  Jun 01 17:37:30 maaxboard systemd[1]: chromium.service: Failed with result 'sig>

                                  Jun 01 17:37:30 maaxboard systemd[1]: Failed to start chromium Browser.