[APKG Desktop_Engine] users, shares, structure (file system)

Moderator: Lillian.W@AST

Post Reply
User avatar
father.mande
Posts: 1815
youtube meble na wymiar Warszawa
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

[APKG Desktop_Engine] users, shares, structure (file system)

Post by father.mande »

Hi,

This information is done following a question from MikeG.6.5 ...
... about access to hx-engine from external, from Asustor side, user ID shared or not, access to entire structure of the Asustor NAS

Lot of questions (but fundamental) ... so hereafter a short explain (short because lot of options exists and can't be explain here (it's not a course :roll: ) )

A) File System structure and sharing folder between Asustor side and hx-engine side :
=== ALL is based on the understand of what is a chroot

A Linux box (like Asustor NAS) have a UNIQUE file structure based on a root folder : /
... ALL sub-folder can be :
... ... direct real file system on the same disk
... ... "mounted file system"
... ... ... a mounted file system is an internal or external disk, an internal or external partition, a network ressource (NFS, SSHFS, CIFS (Windows share), etc. ), etc.
... ... ... each of them are "mounted" (attached to a folder in the original linux file system : / )
... ... ... SO for ex. in Asustor ... the Raid md0 (2GB) is mounted on (so accessible via) /volume0 , le Raid md1 (largest part of disk) is mounted on /volume1
... ... ... specific mount exist it's for example to create a second access for the same existing folder
... ... ... SO for ex. in Asustor ... the folder /volume1/Public is also mounted on /share/Public
THE BIG advantage of "mount" compare to other method like link, etc. is that Linux consider the data as local (so manage access right, etc. as local ) as if they are on the "real" disk ...
OK ... now we can continue with hx-engine

hx-engine is a chroot ... a sort of jail and as is name (chroot) said is to "CHANGE THE ROOT FOLDER"
... so when you enter in hx-engine ... the "/" you see IS NOT the "/" of the linux box ... it's a NEW ONE with a similar structure (/bin, /etc, /usr etc.)
... in the chroot (if you don't use specific tools)
... ... YOU DON'T have access to the real / and subfolder (ex. hx-engine new / is /usr/local/AppCentral/hx-engine/my_asustor ) and see ONLY what is visible in your NEW ROOT FOLDER
BUT chroot shared (by construction) some parts with the host (system where it run here the Asustor NAS)
... it share the kernel and kernel modules ... so if you want to use new modules in a chroot (hx-engine) you MUST create it and load it in the host (Asustor NAS)
... it share the network ... so have the SAME I.P. address and CAN'T USE tcp or udp port ALREADY in use in the host (Asustor NAS)
BUT chroot DON'T share ... users (except root and some identical system user) ... services (dbus, udev, etc.) ... servers running in the NAS (but after entering the service some access can exist from NAS to chroot) like ssh-server, web server, etc.

Question (from Mike) :
Can I access to ALL data of the NAS ?
Response :
YES and NO (good response is not it ?)
from host (Asustor NAS) you can open visibility to a folder in the NAS to the chroot, it's done by "mounting" an existing folder in the NAS to an existing folder in the chroot (it's a bind)
so for ex. I can mount /share/Public to a folder in the chroot ex. /usr/local/AppCentral/hx-engine/my_asustor/share/Public (YOU CAN SEE that it's a view from NAS linux point of view)
the target folder MUST exist
hx-engine have an auto-mount mechanism based on ONLY FOLDER available in /share (NAS) ... it's a list of folder can be add, edit, remove from hx_manage tools
hx-engine also provide another shell (other_mount.sh) to add OTHERS folders (not from /share ... )
BUT REMEMBER to don't create loop ... for ex. if you mount in the chroot : /volume1 to have ALL the disk) ... you create a loop because hx-engine is already in the /volume1 ... so error can appear ...

Question :
Is using /share in the chroot is mandatory ?
Response :
ABSOLUTELY NOT ... I use /share in chroot to mount /share in NAS folder to keep the same visibility for the user ...

Question (from Mike) :
So, saying that, let me give some parameters with bogus passwards and such, and if you don't mind, Philippe, would you give the command line and tell me whether it is run in the terminal in HDMI or run in a WinSCP terminal window.
Example: UserID: admin Password : testing_access <--- exists in the ADM Access Control
USerID: Stupid_idiot Password: TooDumbToFigureitout <--- Does NOT exist in ADM Access Control
In Terminal (winSCP) I type what?
In HDMI hx_engine I type what?
... THIS question is about user management ... and by nature ... access right to the file ...
Response :
YOU MUST understand that user in Asustor side ARE TOTALLY managed in another way then users in chroot hx-engine
each side have a private /etc/passwd (list of users) /etc/group (group available) /etc/shadow (encrypted password)
THE ONLY (at start) commons users between NAS and hx-engine (chroot) are root (real) and all the system user (if they use the default UID)
YOU MUST remember that user don't really exist ... it's just a name ASSOCIATED to a U.I.D. (User ID) ... idem for group
... so for ex. admin user in NAS side (UID 99) don't exist in chroot even it use an UID < 100 so normally reserved for system users ... same for ALL users (not system) existing in NAS DON'T exist in chroot

WHEN you are connected in the NAS ... as a console ... you can switch INSIDE the chroot ONLY only as root (or from root to user)
WHEN you use a service (ex. ssh) in the NAS ... you can ONLY used users define IN the NAS
IF you use another service started IN THE CHROOT (like another ssh server with a different TCP Port) ... you can use ONLY users define in the chroot

exemples :
you are connected as root in the NAS ; then you use hdechrt or hx_manage enter ... you switch to chroot as root user
you are connected as admin in the NAS ; then try using hdechrt ... you fall in error ... admin is NOT AUTHORIZED as ANY USERS to use chroot
you are connected as root in the NAS ; then use chroot (Entware version) with other_user:group (target other_user define IN the chroot) ... you switch to chroot as other_user
you are connected (another server) in the chroot ... you can use ANY user (chroot) BUT don't have any view of NAS part (except mounted point ... as explain before ... )

Solution :
from NAS to chroot (hx-engine)
... use root to NAS login ; then hdechrt to switch to chroot ... then su - user to switch to a specific chroot's user
... use root to NAS login ; then use chroot from Entware with user:group ... to switch to a specific chroot's user
Directly in the chroot
... start a service (ssh server) and connect to it using Winscp, putty, etc.) using the different port ... then use ANY chroot (hx-engine) user

To start a shell (pre-define) in chroot from NAS
1) use
chroot command args
or
hdcechrt command args
UNDERSTAND that chroot DON'T ADD ALL ENVIRONMENT ... so best is that command = script with a shebang and setting environment needed.
... also script can swicth (using su) to any user to start a specific service under a user
or
/opt/bin/chroot --userspec=USER_in_chroto:GROUP_in_chroot command args ... so command is executed under the user_in_chroot user inside the chroot
2) use
myserv ... inter exchange server between NAS to hx-engine (chroot) AND REVERSE ... (another post will be write )

Another way is to create clone of NAS user in the chroot ... so UID and Groups are same ... so access right are also the same
THE INTEREST is to get access to file and folder based on access rigth (real access is managed through UID and GID not on the name ... who is only a "facility" for usage ...
exemple ... create an admin clone in chroot (admin have UID = 99 (so < 100 ... so considered as a system user) ... for "normal" user just delete --system argument)
login as root in the NAS ... enter as root in chroot : (for info. id of admin is : uid=999(admin) gid=999(administrators) groups=100(users),999(administrators) )
hdechrt
THEN create group administrators
addgroup --system --gid 999 administrators
THEN add the user admin
adduser --system --home /home/admin --shell /bin/bash --uid 99 --gecos "Admin clone" --ingroup administrators admin
THEN add admin user to "users" group (as in NAS)
adduser admin users
THEN add a password (same or different)
passwd admin

... NOW the user admin now exist with same UID/GID than in NAS so same access rigth ...
verify :
exit the chroot
exit
switch to admin user (from root NAS user) in the chroot (hx-engine)

Code: Select all

# /opt/bin/chroot --userspec=admin:administrators /usr/local/AppCentral/hx-engine/my_asustor /bin/bash
admin@AS5002TaPhil:/$ id
uid=99(admin) gid=999(administrators) groups=999(administrators),100(users)
admin@AS5002TaPhil:/$
SAME can be done with your others users (create a simple bash script to automatize the process)
hx-engine pre-define users use UID 65000 and more ... so can't conflict with your own ...

3) use HDMI screen
HDMI screen is INSIDE THE CHROOT ... so can see ONLY
... shared resource mounted from NAS in the chroot
... switch to user define in chroot
... use myserv exchange server to start some shell script in NAS side
... THE USER (default) astuser) CAN BE CHANGED to use an existing user if you want ...
... ... 1 as here before CREATE the user in chroot with SAME caracteristic (if needed) as define in NAS part
... ... 2 stop desktop using hx_manage (or disable hx-engine)
... ... 3 change user use for desktop HDMI screen using hx_manage
... ... 4 restart desktop (so all is created as a new desktop ... so you can have to put settings as you want) when it propose use default desktop (more easy compare to empty desktop)

Philippe.
NB feel free to comment, add remarks ... or said .. it's NOT understandable ... this part ... so rewrite ... :lol: :lol:
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
MikeG.6.5
Posts: 917
Joined: Fri May 15, 2015 1:56 am

Re: [APKG Desktop_Engine] users, shares, structure (file system)

Post by MikeG.6.5 »

OK, I am now getting beyond frustrated, here....

I went back to the default astuser to retest the browsers and yeah, they work there. So it appears to be a permissioning error for not getting it working with the admin user cloned from the ADM.

What I hope we can get to is something like what we get with WinSCP, where I can see the entire device from within WinSCP and interact with it as if I were the same user ID as an administrator of the ADM. So I can start/stop applications on a DEVICE level and not on a jailed level.

I made an administrator clone ID by doing the following commands in PuTTY from a WinSCP session on my laptop:

Code: Select all

hdechrt
addgroup --system --gid 999 administrators
adduser --system --home /home/admin --shell /bin/bash --uid 99 --gecos "Admin clone" --ingroup administrators admin
adduser admin users
passwd admin
The last one prompted me 2 times for a password and accepted the entered password.

Now to change to the new user on the desktop I have to exit it, if it is running, and then on a terminal window type the following:

hx_manage change_user admin

Then I go into the desktop folder for the astuser and try to copy the desktop icons for chrome, PHT, Netflix, etc. to the Admin desktop folder. These copied, and looking at them in WinSCP I can see I have full rights as admin to execute, read and write.

BUT the only one I can get to work is the PHT shortcut.

I MADE shortcuts to Calibre and PlexRequests.net on the Admin's desktop. These are working as intended, but I can't do any updates to them, as the browser isn't functional. I have to close the desktop, open the site on my laptop, download the updates, then put them into a folder that the desktop can see and extract/run to update. Then open the desktop and the new updated apps are working fine.

If I open Calibre on the astuser ID on the desktop the data points to a whole new folder than the database I have already made on the admin account. If I try to run PlexReqests.net (made on the admin account) on the astuser account, it opens quickly, then closes, so I assume it's again permissions not allowing me access to the files/folders.

Now I realize that this is a JAIL of sorts. And that each user has access to some things, based on permissions. I fully get that...

So, Philippe here's what I want to know if we can do....

1) Administrators are ADMINS! They should have full rights to everything on the system, regardless, right? So why can't the admin account (which is a clone of the admin account from the ADM) have full R/W/X of anything from other users on the desktop?

2) Admins should have full access to the ENTIRE drive system. I can't "mount" my drives in either account, admin or astuser. I can't even see the contents of the externals, or volume 2 (10TB Raid 5 internal to the NAS.) The shortcuts exist on the desktop, but I can't USE them. How can I get to the individual drives and not just the chroot?

3) How can I get at apps installed on astuser to execute them as admin? (such as chrome, Netflix, etc.)

4) How can I get the PMP application to run on the desktop rather than dropping back to ASPortal every time I want to start it? I have apps I run on the desktop in the admin account that my users need access to. I can't shut down the desktop to use PMP all of the time...

I had a few other thoughts, but I think this is probably enough for now
User avatar
father.mande
Posts: 1815
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: [APKG Desktop_Engine] users, shares, structure (file system)

Post by father.mande »

Hi MickeG.6.5,

Due to the lack of activity on hx-engine ... I have not follow it (just start it again in each update of A.D.M. or Xorg ... )
Also I have had a limited activity during the last three months (some personal problems) ... as you know (even if I repeat me too much) ... I works on my free time and only for the challenge to run some interesting things (for me) on Asustor ... so I can't spent lot of time as professional team (I am alone) to be sure to have tested all and all cases ...

BUT I will restart a test in your context A.S.A.P. ...

I just can confirm that I have never include admin in my scope ... because the real administrator is root and admin appear to be so special ... I never test to clone it.

remember also that if you use Linux A.C.L. ... not sure this will be reported in the hx-engine chroot (jail) ...
I also think that you can add admin (in hx-engine) in the root user group (also audio and video group to Xserver)

BUT I will test.

last : when you said PMP did you speak about the Plex Media Player ? ... if yes the error when leaving is strange ... BUT clearly it's not a so hard work to have it working in hx-engine ... I will try to write an how-to ... but please be patient PMP will be delivered for ALPHA test just ONE day ago :lol: :roll:

Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
User avatar
father.mande
Posts: 1815
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: [APKG Desktop_Engine] users, shares, structure (file system)

Post by father.mande »

Hi,
first part of my view :
1) Administrators are ADMINS! They should have full rights to everything on the system, regardless, right? So why can't the admin account (which is a clone of the admin account from the ADM) have full R/W/X of anything from other users on the desktop?
In fact in a Linux environment ... nor admin (not ID 0) users nor administrators (not GID 0) can have access to file and more to file where the owner is root and only root have read / write permissions ...
so the question (and I don't have the response) is how admin can get access to root file even it's a "normal" user (even system) ??? in ADM O.S.

In Asustor side I can modify a file under root:root with only owner access right
like

Code: Select all

-rwxr-xr-x    1 root     root         542 Oct  5 14:34 env.sh
... clearly it's not what is expected in a Linux system
... and more ALL ID in administrators group is able to modify file even owned by root ONLY
ex. this file can be modified by root (OK) by admin (?) but also by my own user in "users" group and "administrators" group ... so so dangerous

So the reason why it don't work in the chroot (jail of Ubuntu 14.04) is : we follow the rules of a standard Linux box ... so a user (whatever is name) but no UID 0 or GID 0 can't modify any file that are not in the same UID 999 for admin or groups 999 for administrators or group where user is attached ...

So my recommendation is to add at minimal the admin users in hx-engine to the root group (so you can have SAME right as the root GID Asustor and hx-engine)
you can add it (admin) in the sudoers file of hx-engine without password (to be able to execute any root command without requesting a password ... )

The capabilities (not standard) of admin (999) user in ADM should be explain by Asustor ... not by me I don't understand and know how they do ...

Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
User avatar
father.mande
Posts: 1815
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: [APKG Desktop_Engine] users, shares, structure (file system)

Post by father.mande »

Hi,
second part :
2) Admins should have full access to the ENTIRE drive system. I can't "mount" my drives in either account, admin or astuser. I can't even see the contents of the externals, or volume 2 (10TB Raid 5 internal to the NAS.) The shortcuts exist on the desktop, but I can't USE them. How can I get to the individual drives and not just the chroot?
Part of response is in part one ... add admin to sudoers without password and you can do mount or what you want ...

The chroot is a JAIL so (even breaking possibility exist (it's what Linux Containers exist)
... consider his own folder (where chroot is called) as the / (base of all the Linux) structure
... so for hx-engine it's /usr/local/AppCentral/hx-engine/my_asustor folder

By build ... chroot (when you go inside) don't see any other parts ...
... to have an access to others folder, disks ... the folder (or mount point) MUST be mounted as BIND on a folder in the chroot
ex. : (you have a volume mounted on /share/my_volume in A.D.M. side (the mkdir is to do only one time the first before mount)
CHR_PATH=/usr/local/AppCentral/hx-engine/my_asustor
mkdir -p $CHR_PATH/share/view_from_chroot
mount -o rbind /share/my_volume $CHR_PATH/share/view_from_chroot

... this mount original ADM share my_volume in the chroot in /share/view_from_chroot folder
... the rbind is better than bind ... to have mount point inside source mounted also
... ex. if /share/my_volume/mnt is also a mount point ... with bind you see nothing in mnt folder with rbind you see the content of the mount in mnt

This can be done at start using the bin/other_mount.sh provide (with example)

BUT you can do for test or non permanent access this at any time BUT in a console of A.D.M. O.S. (so if you are in hx-engine ... use a terminal and do a ssh loopback in ADM side ... )

If you want to do it from hx-engine ... (ex. with an icon ... ) you can use the exchange server from the two side .

Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
User avatar
father.mande
Posts: 1815
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: [APKG Desktop_Engine] users, shares, structure (file system)

Post by father.mande »

Hi,
third part :
3) How can I get at apps installed on astuser to execute them as admin? (such as chrome, Netflix, etc.)
Nor sure to understand ... BUT if the question is how I get icons to start applications ...

just copy (as admin) the Desktop folder astuser ... this is the place where all the icons in astuser are describe ... then read each to adapt if needed ...

Code: Select all

HX_Engine astuser@AS5002TaPhil:~/Desktop$ ll
total 36
-rwxr-xr-x 1 astuser users 161 Mar 20  2016 Chrome V_48.desktop
-rwxr-xr-x 1 astuser users 143 Apr 26 17:55 Kodi 16 local.desktop
-rwxr-xr-x 1 astuser users 182 Apr 26 17:55 Kodi from ASUTOR side.desktop
-rwxr-xr-x 1 astuser users 225 Apr 26 17:55 Netflix (HTML5 client).desktop
-rwxr-xr-x 1 astuser users 193 Jul  2 18:24 PlexHomeTheater.desktop
-rwxr-xr-x 1 astuser users 170 Apr  9 17:34 VLC  Plyer.desktop
-rwxr-xr-x 1 astuser users 205 Jul  2 18:25 View_Xfvb_Screen.desktop
-rwxr-xr-x 1 astuser users 171 Apr 19 14:02 Xvt.desktop
-rwxr-xr-x 1 astuser users 201 Apr 27 18:02 stremio.desktop
HX_Engine astuser@AS5002TaPhil:~/Desktop$
Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
User avatar
father.mande
Posts: 1815
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: [APKG Desktop_Engine] users, shares, structure (file system)

Post by father.mande »

hi,
fourth part :
4) How can I get the PMP application to run on the desktop rather than dropping back to ASPortal every time I want to start it? I have apps I run on the desktop in the admin account that my users need access to. I can't shut down the desktop to use PMP all of the time..
PMP have been build on Ubuntu 14.04 so can run in hx-engine or move and reinstall ... I will run a short test and write a how-to /// but please wait ... I am waiting for return of experience (you, damien, perhaps other people) to be sure that the APKG is stabilized (it's one of the more complex build I never integrate ... but I am limited (competency and time).

Philippe.
NB remember that another virtual screen run in the background ... so if it's to don't stop server running in Desktop ... a possible way is to run server in the virtual screen (:99) and keep hx-engine free to client able to be stopped quickly ... )
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
Post Reply

Return to “Desktop_Engine”