Mailing List Archive

UserJob setup
I'm trying to create my own user job in mythtv, built from sendTVtoNAS. It
works if I run it from the console with the parameters it would be passed
from the database as arguments.

However, if I run it from mythfrontend. it gets queued but when it shows
complete without error, it really hasn't worked. I have some dummy echoes
to a log file that happen immediately on start of the .sh and there isn't
even a log file.

It sounds like a permissions issue but I'm not sure where to check. The
.sh file is in /usr/local/bin with +x on everyone. The workdir for the
command is in /home/jim/Videos that has permissions 777. User jim is part
of group mythtv. I'm assuming that the background userjobs run as user
mythtv.

When I look at the journalctl output it shows:

Jun 06 17:53:56 ubuntu-mythtv mythbackend[1004]: mythbackend[1004]: I
UserJob_25 jobqueue.cpp:2433 (DoUserJobThread) JobQueue: Started
sendTVtoNAS for "Mission: Impossible Rogue
Nation" recorded from channel 15009 at 2023-06-06T00:00:00Z
Jun 06 17:53:56 ubuntu-mythtv mythbackend[1004]: mythbackend[1004]: I
UserJob_25 jobqueue.cpp:2485 (DoUserJobThread) JobQueue: Finished
sendTVtoNAS for "Mission: Impossible Rogu
e Nation" recorded from channel 15009 at 2023-06-06T00:00:00Z

The parameters in setup are:
/usr/local/bin/TVShowToNAS.sh "%CHANID%" "%STARTTIMEUTC%" "%TITLE%"
"%SUBTITLE%" "%SEASON%" "%EPISODE%" "%FILE%" "%DIR%"

The permissions of the .sh are:
mythtv@ubuntu-mythtv:~$ ls -l /usr/local/bin/TVShowToNAS.sh
-rwxr-xr-x 1 root root 6195 Jun 6 17:47 /usr/local/bin/TVShowToNAS.sh

So what did I miss??

Jim A
Re: UserJob setup [ In reply to ]
On Tue, Jun 6, 2023 at 7:01?PM James Abernathy <jfabernathy@gmail.com>
wrote:

> I'm trying to create my own user job in mythtv, built from sendTVtoNAS. It
> works if I run it from the console with the parameters it would be passed
> from the database as arguments.
>
> However, if I run it from mythfrontend. it gets queued but when it shows
> complete without error, it really hasn't worked. I have some dummy echoes
> to a log file that happen immediately on start of the .sh and there isn't
> even a log file.
>
> It sounds like a permissions issue but I'm not sure where to check. The
> .sh file is in /usr/local/bin with +x on everyone. The workdir for the
> command is in /home/jim/Videos that has permissions 777. User jim is part
> of group mythtv. I'm assuming that the background userjobs run as user
> mythtv.
>
> When I look at the journalctl output it shows:
>
> Jun 06 17:53:56 ubuntu-mythtv mythbackend[1004]: mythbackend[1004]: I
> UserJob_25 jobqueue.cpp:2433 (DoUserJobThread) JobQueue: Started
> sendTVtoNAS for "Mission: Impossible Rogue
> Nation" recorded from channel 15009 at 2023-06-06T00:00:00Z
> Jun 06 17:53:56 ubuntu-mythtv mythbackend[1004]: mythbackend[1004]: I
> UserJob_25 jobqueue.cpp:2485 (DoUserJobThread) JobQueue: Finished
> sendTVtoNAS for "Mission: Impossible Rogu
> e Nation" recorded from channel 15009 at 2023-06-06T00:00:00Z
>
> The parameters in setup are:
> /usr/local/bin/TVShowToNAS.sh "%CHANID%" "%STARTTIMEUTC%" "%TITLE%"
> "%SUBTITLE%" "%SEASON%" "%EPISODE%" "%FILE%" "%DIR%"
>
> The permissions of the .sh are:
> mythtv@ubuntu-mythtv:~$ ls -l /usr/local/bin/TVShowToNAS.sh
> -rwxr-xr-x 1 root root 6195 Jun 6 17:47 /usr/local/bin/TVShowToNAS.sh
>
> So what did I miss??
>
> Jim A
>
>
I think I know what the problem is, but I don't understand why.

I changed the script so that my working directory was in /tmp instead of
/home/jim/Videos and the script ran when launched from mythfrontend.

I could see the problem if /home/jim/Videos wasn't 777 permissions, but
there must be new restrictions since ATT SysV release 4 when I got started
with Unix.

Jim A
Re: UserJob setup [ In reply to ]
On Tue, 6 Jun 2023 21:25:17 -0400, you wrote:

>On Tue, Jun 6, 2023 at 7:01?PM James Abernathy <jfabernathy@gmail.com>
>wrote:
>
>> I'm trying to create my own user job in mythtv, built from sendTVtoNAS. It
>> works if I run it from the console with the parameters it would be passed
>> from the database as arguments.
>>
>> However, if I run it from mythfrontend. it gets queued but when it shows
>> complete without error, it really hasn't worked. I have some dummy echoes
>> to a log file that happen immediately on start of the .sh and there isn't
>> even a log file.
>>
>> It sounds like a permissions issue but I'm not sure where to check. The
>> .sh file is in /usr/local/bin with +x on everyone. The workdir for the
>> command is in /home/jim/Videos that has permissions 777. User jim is part
>> of group mythtv. I'm assuming that the background userjobs run as user
>> mythtv.
>>
>> When I look at the journalctl output it shows:
>>
>> Jun 06 17:53:56 ubuntu-mythtv mythbackend[1004]: mythbackend[1004]: I
>> UserJob_25 jobqueue.cpp:2433 (DoUserJobThread) JobQueue: Started
>> sendTVtoNAS for "Mission: Impossible Rogue
>> Nation" recorded from channel 15009 at 2023-06-06T00:00:00Z
>> Jun 06 17:53:56 ubuntu-mythtv mythbackend[1004]: mythbackend[1004]: I
>> UserJob_25 jobqueue.cpp:2485 (DoUserJobThread) JobQueue: Finished
>> sendTVtoNAS for "Mission: Impossible Rogu
>> e Nation" recorded from channel 15009 at 2023-06-06T00:00:00Z
>>
>> The parameters in setup are:
>> /usr/local/bin/TVShowToNAS.sh "%CHANID%" "%STARTTIMEUTC%" "%TITLE%"
>> "%SUBTITLE%" "%SEASON%" "%EPISODE%" "%FILE%" "%DIR%"
>>
>> The permissions of the .sh are:
>> mythtv@ubuntu-mythtv:~$ ls -l /usr/local/bin/TVShowToNAS.sh
>> -rwxr-xr-x 1 root root 6195 Jun 6 17:47 /usr/local/bin/TVShowToNAS.sh
>>
>> So what did I miss??
>>
>> Jim A
>>
>>
>I think I know what the problem is, but I don't understand why.
>
>I changed the script so that my working directory was in /tmp instead of
>/home/jim/Videos and the script ran when launched from mythfrontend.
>
>I could see the problem if /home/jim/Videos wasn't 777 permissions, but
>there must be new restrictions since ATT SysV release 4 when I got started
>with Unix.
>
>Jim A

When the script logs to /tmp, the ownership of the log file should
tell you what user is running the script. User jobs are normally run
by mythbackend - all mythfrontend does is to queue them for
mythbackend to run them.

To solve difficult permissions problems, you can use ACLs to apply
fine grained permissions. It is also possible in the worst case to
get your script to run a helper script that is run using sudo and has
special permissions in the /etc/sudoers.d files. Then the helper
script can do things as root.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: UserJob setup [ In reply to ]
On Wed, 7 Jun 2023 at 02:27, James Abernathy <jfabernathy@gmail.com> wrote:

> On Tue, Jun 6, 2023 at 7:01?PM James Abernathy <jfabernathy@gmail.com>
> wrote:
>
>> It sounds like a permissions issue but I'm not sure where to check. The
>> .sh file is in /usr/local/bin with +x on everyone. The workdir for the
>> command is in /home/jim/Videos that has permissions 777. User jim is part
>> of group mythtv. I'm assuming that the background userjobs run as user
>> mythtv.
>>
>
What are the permissions on /home/jim (ls -lad /home/jim)?

Cheers, Ian
Re: UserJob setup [ In reply to ]
On Wed, Jun 7, 2023 at 6:14?AM Ian Cameron <mkbloke@gmail.com> wrote:

> On Wed, 7 Jun 2023 at 02:27, James Abernathy <jfabernathy@gmail.com>
> wrote:
>
>> On Tue, Jun 6, 2023 at 7:01?PM James Abernathy <jfabernathy@gmail.com>
>> wrote:
>>
>>> It sounds like a permissions issue but I'm not sure where to check. The
>>> .sh file is in /usr/local/bin with +x on everyone. The workdir for the
>>> command is in /home/jim/Videos that has permissions 777. User jim is part
>>> of group mythtv. I'm assuming that the background userjobs run as user
>>> mythtv.
>>>
>>
> What are the permissions on /home/jim (ls -lad /home/jim)?
>
> Cheers, Ian
>
>
jim@ubuntu-mythtv:~$ ls -lad /home/jim
drwxr-x--- 1 jim jim 430 Jun 6 12:12 /home/jim

And the working direct for the .sh
jim@ubuntu-mythtv:~$ ls -lad /home/jim/Videos
drwxrwxr-x 1 jim mythtv 126 Jun 6 21:51 /home/jim/Videos

Jim A
Re: UserJob setup [ In reply to ]
On Wed, 7 Jun 2023 at 11:30, James Abernathy <jfabernathy@gmail.com> wrote:

>
> jim@ubuntu-mythtv:~$ ls -lad /home/jim
> drwxr-x--- 1 jim jim 430 Jun 6 12:12 /home/jim
>

Perhaps the best solution in this arrangement would be to:

sudo usermod -aG jim mythtv

Another option is:

chmod 751 /home/jim

but that allows potentially more access than might be desirable.

Cheers, Ian
Re: UserJob setup [ In reply to ]
On Wed, Jun 7, 2023 at 6:53?AM Ian Cameron <mkbloke@gmail.com> wrote:

> On Wed, 7 Jun 2023 at 11:30, James Abernathy <jfabernathy@gmail.com>
> wrote:
>
>>
>> jim@ubuntu-mythtv:~$ ls -lad /home/jim
>> drwxr-x--- 1 jim jim 430 Jun 6 12:12 /home/jim
>>
>
> Perhaps the best solution in this arrangement would be to:
>
> sudo usermod -aG jim mythtv
>
> Another option is:
>
> chmod 751 /home/jim
>
> but that allows potentially more access than might be desirable.
>
> Cheers, Ian
>
> Interesting. while I think just using the working directory in /tmp, I'd
like to understand this permissions thing.

When logged in as jim:
uid=1000(jim) gid=1000(jim)
groups=1000(jim),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),118(lpadmin),130(sambasha
re),200(mythtv)

When logged in as mythtv:
uid=200(mythtv) gid=200(mythtv)
groups=200(mythtv),20(dialout),24(cdrom),27(sudo),29(audio),44(video),100(users)

So I'll add mythtv to group jim and see what happens.

Thanks,
Jim A
Re: UserJob setup [ In reply to ]
On Wed, Jun 7, 2023 at 6:59?AM James Abernathy <jfabernathy@gmail.com>
wrote:

>
>
> On Wed, Jun 7, 2023 at 6:53?AM Ian Cameron <mkbloke@gmail.com> wrote:
>
>> On Wed, 7 Jun 2023 at 11:30, James Abernathy <jfabernathy@gmail.com>
>> wrote:
>>
>>>
>>> jim@ubuntu-mythtv:~$ ls -lad /home/jim
>>> drwxr-x--- 1 jim jim 430 Jun 6 12:12 /home/jim
>>>
>>
>> Perhaps the best solution in this arrangement would be to:
>>
>> sudo usermod -aG jim mythtv
>>
>> Another option is:
>>
>> chmod 751 /home/jim
>>
>> but that allows potentially more access than might be desirable.
>>
>> Cheers, Ian
>>
>> Interesting. while I think just using the working directory in /tmp, I'd
> like to understand this permissions thing.
>
> When logged in as jim:
> uid=1000(jim) gid=1000(jim)
> groups=1000(jim),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),118(lpadmin),130(sambasha
> re),200(mythtv)
>
> When logged in as mythtv:
> uid=200(mythtv) gid=200(mythtv)
> groups=200(mythtv),20(dialout),24(cdrom),27(sudo),29(audio),44(video),100(users)
>
> So I'll add mythtv to group jim and see what happens.
>
> Thanks,
> Jim A
>

I added user mythtv to group jim, logged out and back in. Running the
userjob from mythtfrontend (as mythtv) would still not use the working dir
in /home/jim/Videos.

However, when I switched the location of the working dir to
/home/mythtv/Videos it worked just like /tmp. So I'll use that since it's
more permanent than /tmp.

Thanks,

Jim A