Snippets Collections
# In Crosh
# Ctrl + Alt + t
vmc start termina
 lxc launch ubuntu:18.04 owo
  lxc file pull owo/usr/bin/lxc /tmp/lxc
  lxc file push /tmp/lxc penguin/usr/local/bin/
  lxc delete owo -f
  lxc config set core.https_address :8443
  lxc config set core.trust_password "a'really,good;password:^)"

# in container terminal
  lxc remote add chronos $(ip route show | awk '{print $3}' | head -n 1)
  lxc remote set-default chronos

# have fun
lxc exec container_name -- bash
# Deal with sudo authentication errors on back up
# two write permissions errors on backup restore:
# 1. check chown and chmod of sudo 
# 2. sudo: /usr/bin/sudo must be owned by uid 0 
# 3. and have the setuid bit set

# 1. sudo ownership
chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo

# 2. UID ownership
grep root /etc/passwd
# the default root should be set to:
# root:x:0:0:root:/root:/bin/bash
# if not sudoedit as above.

# 3. setuid bit
# check /usr/bin for setuid bit errors (vs. clean normal installation of distro)
# (for debian 11) incorrect configuration includes su and sudo and 8 other executables
# Incorrect format is (compare first 4 permsissions) 
# -rwxr-xr-x 1 root root 179K Feb 27 2021 sudo
# correct format is 
# -rwsr-xr-x 1 root root 182600 Feb 27  2021 /usr/bin/sudo
# prefer pkexec to nake changes 
pkexec chmod a=rx,u+ws /usr/bin/sudo
pkexec chmod a=rx,u+ws /usr/bin/su
# compare vs. a unmodified fresh virtual install of your system
# in Debian 11 8 further files need modifying

# bonus. on your way out check permissing in  /usr/lib/sudo/ and compare with base install.
# When using a number mask for permission representation there are only a few basic permissions

4: Read
2: Write
1: Execute

# Combined you get this table

+-----+---+--------------------------+
| rwx | 7 | Read, write and execute  |
| rw- | 6 | Read, write              |
| r-x | 5 | Read, and execute        |
| r-- | 4 | Read,                    |
| -wx | 3 | Write and execute        |
| -w- | 2 | Write                    |
| --x | 1 | Execute                  |
| --- | 0 | no permissions           |
+------------------------------------+
  
# The permissions for user, group and other are listet after each other when looking them up

+------------+------+-------+
| Permission | Octal| Field |
+------------+------+-------+
| rwx------  | 700  | User  |
| ---rwx---  | 070  | Group |
| ------rwx  | 007  | Other |
+------------+------+-------+
  
# This boils down to this
  
  +------------------------+-----------+
| chmod u=rwx,g=rwx,o=rx | chmod 775 | For world readable directories
|                        |           |   Members of group can change files
| chmod u=rwx,g=rx,o=    | chmod 750 | For group readable directories
|                        |           |   Members of group can change files
| chmod u=rwx,go=        | chmod 700 | For private direcories
+------------------------+-----------+
# Check if 'webmasters' group exist

cat /etc/group | grep webmasters

# Create 'webmasters' group

sudo addgroup webmasters

# Add users to 'webmasters' group

sudo usermod -a -G webmasters username

# Group assignment changes won't take effect
# until the users log out and back in.


# Change group owner of the directory to webmaster user

sudo chgrp -R webmasters /etc/nginx/
  
# Give write permission to the group

sudo chmod -R g+w /etc/nginx/
  
# Create file as different user

sudo -u username touch /etc/nginx/test.txt
private fun askPermissions(){
        Dexter.withContext(this)
                .withPermissions(
                        Manifest.permission.ACCESS_FINE_LOCATION,
                        Manifest.permission.ACCESS_COARSE_LOCATION
                )
                .withListener(object : MultiplePermissionsListener {
                    override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
                        if (report!!.areAllPermissionsGranted()) {
                            // TODO (STEP 7: Call the location request function here.)
                        }

                        if (report.isAnyPermissionPermanentlyDenied) {
                            Toast.makeText(
                                    this@MainActivity,
                                    "You have denied location permission. Please allow it is mandatory.",
                                    Toast.LENGTH_SHORT
                            ).show()
                        }
                    }

                    override fun onPermissionRationaleShouldBeShown(
                            permissions: MutableList<PermissionRequest>?,
                            token: PermissionToken?
                    ) {
                        showRationalDialogForPermissions()
                    }
                }).onSameThread()
                .check()

    }
star

Mon Oct 03 2022 15:50:07 GMT+0000 (Coordinated Universal Time) https://github.com/edeloya/ChromeOS-Terminal-LXC-LXD

#permissions #shell #backup #chromeos
star

Mon Jun 21 2021 20:45:00 GMT+0000 (Coordinated Universal Time) https://www.grymoire.com/Unix/Permissions.html

#authentification #permissions
star

Mon Jun 21 2021 20:32:43 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/488485/allowing-a-group-read-write-access-to-a-directory

#authentification #permissions
star

Sat Jan 09 2021 10:28:12 GMT+0000 (Coordinated Universal Time)

##kotlin,#java,#android #permissions #dexter #location #weatherapp

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension