[mythtv] [mythtv-commits] Ticket #3437: Invalid argument to 'find' in mythweb video module scan collection

Michael T. Dean mtdean at thirdcontact.com
Wed May 9 15:40:09 UTC 2007


On 05/09/2007 10:59 AM, MythTV wrote:
> #3437: Invalid argument to 'find' in mythweb video module scan collection
> -----------------------+----------------------------------------------------
>  Reporter:  anonymous  |       Owner:  xris   
>      Type:  defect     |      Status:  new    
>  Priority:  minor      |   Milestone:  unknown
> Component:  mythweb    |     Version:  head   
>  Severity:  medium     |  
> -----------------------+----------------------------------------------------
>  scan.php includes the argument '-readable' to the find command which on
>  the find included with findutils 4.2.27 (CentOS 5.0) is not valid:
>
>  {{{
>  [darryl at server1 mythweb]$ find /mnt/media1/videos/ -readable -type f
>  find: invalid predicate `-readable'
>  }}}
>
>  The man page suggests '-perm -a+r'. I have a patch which I will attach in
>  a sec.

find -perm -a+r only matches files that are readable by every user (i.e. 
user (owner), group, /and/ other).  The mode you used in the attached 
patch was actually "-a-r", which matches every file.  find -perm /a+r 
finds files that are readable by any user (i.e. user (owner), group, 
/or/ other, not exclusive).

I have no idea what the "-readable" argument is supposed to do, but only 
finding files that can be read by every user is not appropriate.  It's 
quite possible I may have files that can only be read by the mythtv user 
(owner) and the mythtv or httpd group (where the apache user is assumed 
to be in that group).

IMHO, the proper check should be whether the user running the PHP script 
(i.e. the user running apache) can read the file.  Since we can't know 
whether that means to do a user or group or other check on the file 
(unless we first check the current user and group memberships for the 
process owner and then test all permutations), using -perm is probably 
not appropriate.

But, as specified by the ticket, the "-readable" argument is not a 
standard argument, so it shouldn't be used, either.

Therefore, the best way may be to actually try to read the file--which 
the file command will do for us on the next line--and handle errors 
appropriately (i.e. by skipping the file).

Mike


More information about the mythtv-dev mailing list