FAQ  •  Register  •  Login

HOWTO: Create a Default Guest User

<<

mrmichaelrb

Serviio newbie

Posts: 5

Joined: Sat Oct 05, 2019 8:38 pm

Post Mon Mar 08, 2021 9:47 am

HOWTO: Create a Default Guest User

I reported this bug over a year ago and it still hasn't been fixed:
New devices have unrestricted access by default

I came up with this work-around which assigns the "Guest" user to any new devices. You can then give the Guest user limited access to only the media that you want guests to be able to access.

To add this work-around:
  1. Create a "Guest" user in Serviio
  2. Check the box for "Enable access for new devices"
  3. Install Apache Derby Tools (to get the ij utility)
      Code:
    # apt install derby-tools
  4. Stop Serviio
      Code:
    # systemctl stop serviio.service
  5. Change to the Serviio's database directory (this may be different on your machine)
      Code:
    # cd /home/pc5dczcbl5yt/serviio-2.1/library
  6. Add a triggers in Serviio's database to make Guest user the default user
      Code:
    # ij
    ij> connect 'jdbc:derby:db';
    ij> CREATE TRIGGER trigger_renderer_insert_guest AFTER INSERT ON renderer FOR EACH STATEMENT MODE DB2SQL UPDATE renderer SET user_id = (SELECT id from users WHERE name = 'Guest') WHERE NOT EXISTS (SELECT * FROM users where users.id = renderer.user_id);
    ij> CREATE TRIGGER trigger_user_delete_guest AFTER DELETE ON users FOR EACH STATEMENT MODE DB2SQL UPDATE renderer SET user_id = (SELECT id from users WHERE name = 'Guest') WHERE NOT EXISTS (SELECT * FROM users where users.id = renderer.user_id);
    ij> UPDATE renderer SET user_id = (SELECT id from users WHERE name = 'Guest') WHERE NOT EXISTS (SELECT * FROM users where users.id = renderer.user_id);
    ij> exit;
  7. Update ownership of transaction files (only necessary if you are not running ij as the serviio user)
      Code:
    # chown -R serviio:serviio .
  8. Start Serviio
      Code:
    # systemctl start serviio.service

If you want to remove this work-around:
  1. Stop Serviio
      Code:
    # systemctl stop serviio.service
  2. Change to the Serviio's database directory (this may be different on your machine)
      Code:
    # cd /home/serviio/serviio-2.1/library
  3. Drop the triggers in Serviio's database
      Code:
    # ij
    ij> connect 'jdbc:derby:db';
    ij> DROP TRIGGER trigger_renderer_insert_guest;
    ij> DROP TRIGGER trigger_user_delete_guest;
    ij> exit;
  4. Update ownership of transaction files (only necessary if you are not running ij as the serviio user)
      Code:
    # chown -R serviio:serviio .
  5. Start Serviio
      Code:
    # systemctl start serviio.service
  6. Remove the "Guest" user in Serviio
<<

atc98092

User avatar

DLNA master

Posts: 5436

Joined: Fri Aug 17, 2012 10:22 pm

Location: Washington (the state)

Post Mon Mar 08, 2021 2:30 pm

Re: HOWTO: Create a Default Guest User

I might point out to other users that this is all based on a Linux OS. So some of the commands and file locations would differ with the Windows OS.
Dan

LG NANO85 4K TV, Samsung JU7100 4K TV, Sony BDP-S3500, Sharp 4K Roku TV, Insignia Roku TV, Roku Ultra, Premiere and Stick, Nvidia Shield, Yamaha RX-V583 AVR.
Primary server: AMD Ryzen 5 5600GT, 32 gig ram, Windows 11 Pro, 22 TB hard drive space | Test server: Intel i5-6400, 16 gig ram, Windows 10 Pro

HOWTO: Enable debug logging HOWTO: Identify media file contents
<<

mrmichaelrb

Serviio newbie

Posts: 5

Joined: Sat Oct 05, 2019 8:38 pm

Post Mon Mar 08, 2021 10:21 pm

Re: HOWTO: Create a Default Guest User

Yes, I only provided the steps for Linux, not Windows or macOS. I only have a Linux install of Serviio, so I can't easily verify the procedure for the other platforms.

However, the Apache Derby Tools (and the "ij" tool in particular) are available for those platforms and so step #6 (adding the triggers) in adding the work-around, and step #3 (dropping the triggers) in removing the work-around should be the same. The database structure is the same on all platforms. The differences will be in how to do the other things like installing and running the Apache Derby Tools, opening a command-line console, changing to the database directory of Serviio, and stopping and restarting the Serviio server.

It's also possible to do this using a different JDBC SQL client, like SQuirreL. I used "ij" because it is light-weight and I can do it on a headless Linux machine over SSH. If you use a different SQL client, then the "CREATE TRIGGER" and "DROP TRIGGER" may need to be wrapped in EXEC/EXECUTE (and modified a little) for it to pass through to the underlying database engine.
<<

atc98092

User avatar

DLNA master

Posts: 5436

Joined: Fri Aug 17, 2012 10:22 pm

Location: Washington (the state)

Post Tue Mar 09, 2021 12:09 am

Re: HOWTO: Create a Default Guest User

I have used SQuirreL to access the DB when I was curious once. I'll probably dive into it again in the future, after I retire. There were some older guidance on using MySQL as the database, and I might like to update that for the 2.x version. Once I've done that, then I can tinker around with a database admin program. I'd like to be able to edit some of the data, similar to what can be done with Plex. It can't be done with the Derby DB, because the developer is using the single connection version, so a admin GUI can't connect while Serviio is running. Using MySQL would remove that limitation, and I have a bit of (older) experience programming in .NET for a MySQL database. I'm probably going to retire this summer, and I need a project. :D
Dan

LG NANO85 4K TV, Samsung JU7100 4K TV, Sony BDP-S3500, Sharp 4K Roku TV, Insignia Roku TV, Roku Ultra, Premiere and Stick, Nvidia Shield, Yamaha RX-V583 AVR.
Primary server: AMD Ryzen 5 5600GT, 32 gig ram, Windows 11 Pro, 22 TB hard drive space | Test server: Intel i5-6400, 16 gig ram, Windows 10 Pro

HOWTO: Enable debug logging HOWTO: Identify media file contents

Return to Serviio Support & Help

Who is online

Users browsing this forum: Baidu [Spider] and 44 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.