devcurmudgeon / ybd

yaml build deploy
GNU General Public License v2.0
6 stars 15 forks source link

Early warning for sudo/root permissions #238

Closed leeming closed 8 years ago

leeming commented 8 years ago

YBD should check for permissions as early as it can. If a normal user is detected, it should exit and warn that YBD should be run with sudo/root/ user with correct permissions.

The following is an example of user unfriendly output

16-08-23 00:00:06 [0/88/88] [fhs-dirs] Try downloading fhs-dirs.61e35e7bcc48112ce3566173efdf7409fd22230a677af533d913976af439ecf9 tar: ./dev/console: Cannot mknod: Operation not permitted tar: ./dev/full: Cannot mknod: Operation not permitted tar: ./dev/null: Cannot mknod: Operation not permitted tar: ./dev/urandom: Cannot mknod: Operation not permitted tar: ./dev/zero: Cannot mknod: Operation not permitted tar: Exiting with failure status due to previous errors

16-08-23 00:00:06 [0/88/88] [fhs-dirs] ERROR: Problem unpacking /home/andrewleeming/ybd/tmp/tmp6lu7l5/fhs-dirs.61e35e7bcc48112ce3566173efdf7409fd22230a677af533d913976af439ecf9

Extract from 'definitions/strata/build-essential/stage2-fhs-dirs.morph' that causes this problem

devices:
- type: c
  filename: /dev/console
  gid: 0
  major: 5
  minor: 1
  permissions: '0600'
  uid: 0

Suggested temporary fix, check for root privileges when running YBD. Alternatively/long term fix, pro-actively check permissions (scan for 'device' key in the dn dict?) and alert user

devcurmudgeon commented 8 years ago

Ideally we would not need root, but it's still not possible to do the sandboxing properly without it. So YBD now checks and exists if os.geteuid() is not 0