[haiku-bugs] Re: [Haiku] #6750: chmod is broken for non-superuser

  • From: "axeld" <trac@xxxxxxxxxxxx>
  • Date: Tue, 26 Oct 2010 20:50:38 -0000

#6750: chmod is broken for non-superuser
-------------------------------+---------------------------------
  Reporter:  grahamh           |        Owner:  axeld
      Type:  bug               |       Status:  new
  Priority:  normal            |    Milestone:  R1
 Component:  File Systems/BFS  |      Version:  R1/Development
Resolution:                    |     Keywords:  chmod, write_stat
Blocked By:                    |  Has a Patch:  0
  Platform:  All               |     Blocking:
-------------------------------+---------------------------------

Comment (by axeld):

 The last two are indeed done by fs_write_stat(). In any case, this would
 still call for a solution like:
 {{{
 if CheckPermissions(..., true)
     update ownership info if requested
 else
    return B_NOT_ALLOWED

 if CheckPermissions(..., false)
     perform the rest of the request changes
 else if requested-non-ownership-changes
     return B_NOT_ALLOWED
 }}}
 The way you suggested in your patch, changing ugo+r file to ugo+rx while
 truncating it in a single fs_write_stat() would actually succeed, but that
 should obviously not be allowed.

 Maybe have a CheckPermissions() version that takes the stat modifier bit,
 ie. like this:
 {{{
 if ((mode & B_STAT_MODE) != 0) {
     status_t status = CheckPermissions(W_OK, B_STAT_MODE);
     if (status != B_OK)
         return status;

     ...
 }
 if ((mode & B_STAT_GID) != 0) {
     status_t status = CheckPermissions(W_OK, B_STAT_GID);
     ...
 }
 }}}

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6750#comment:3>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: