Tuesday, February 2, 2016

Permission permission permission

It's always about permission, permission and permission.

The thing is the PERMISSION can be of GROUP/USER.

So let's see Users first.
  • root - the O'might one in linux
    • There is also a root group
  • Then there is wheel
    • There are a few places to look at
      • /etc/sudoers or visudo - same file
        • Enable wheel group
        • Search for "# %wheel ALL=(ALL)ALL", and remove hash to enable
      • /etc/passwd
        • Enable user/s in group directory for access and bash login
  • Verify user in which group
    • Terminal# su USERNAME -
    • Terminal# groups
  • There are also users like your administrators, users, APACHE and so on...
So now we come to Groups.
  • Group  : root
    • ## Allow root run any commands anywhere
    • "root ALL=(ALL) ALL"
      • So DO NOT anyhow tamper with anything you DO NOT know~!
  • Group : wheel
    • ## Allow people in group wheel to run all commands
    • "%wheel ALL=(ALL) ALL"
      • OR
    • ## Same thing without a password
    • "%wheel ALL=(ALL) NOPASSWD: ALL"
Linux Command : chown
  • To change user and/or group ownership of file/directory
    • chown owner-user "file"
    • chown owner-user:owner-group "file"
    • chown owner-user:owner-group "directory"
    • chown <options> owner-user:owner-group "file"
For /etc/hostapd and /etc/hostapd/hostapd.conf to be accessible by web server, (user: apache)
  1. Changing the owner-user and owner-group of /etc/hostapd/ (directory) and /etc/hostapd/hostapd.conf (file) to apache:wheel
    1. Terminal# chown apache:wheel /etc/hostapd/
    2. Terminal# chown apache:wheel /etc/hostapd/hostapd.conf
  2. This will enable the webpage to access and make changes to "hostapd.conf"
  • To verify if it works, enable bash login for user apache and adding apache into wheel group
    • Terminal# usermod -aG wheel apache
      • Verify by
        • Terminal# cat /etc/group | grep apache
        • Display : wheel:x:10:...,apache
    • Terminal# chsh -s /bin/bash apache
      • Verify by
        • Terminal# cat /etc/passwd | grep apache
          • OR
        • Just edit the "/etc/passwd"
        • Before => Display : apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
        • After => Display : apache:x:48:48:Apache:/usr/share/httpd:/bin/bash
    • Terminal# su apache
      • Then run any command that will write/read/execute the file in "/etc/hostapd"

Reference

No comments:

Post a Comment