Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ".cache" references with the "$AMCACHEDIR" variable / added write control on installed app directories / conversion in functions of the processes to update apps and generate the options list #622

Merged
merged 26 commits into from
Jun 4, 2024

Conversation

ivan-hc
Copy link
Owner

@ivan-hc ivan-hc commented Jun 3, 2024

In reference to https://github.com/ivan-hc/AM/discussions/616 and as previously announced, this change should allow more flexibility for "AM" when used on systems with multiple user accounts.

From an idea of @Samueru-sama

modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
modules/management.am Show resolved Hide resolved
@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

@Samueru-sama as I've said in the discussion, all works without errors now:

  • APP-MANAGER was already updatable, thanks to the work done on the option --user and the AppMan mode;
  • all modules can be updated brom both the admin or a common guest user.

Strange fact is that the lists are updatable for both admin and guest.

Last and more important thing: we can't update the apps (as guest)!

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

Last and more important thing: we can't update the apps (as guest)!

@Samueru-sama In fact, there are indeed problems of inconsistency:

  • if there are two system admins and each of them installs one app, the other admin can't update the one installed from the other admin;
  • if an app has been updated from another user, the version will appear not updated for another, this is because in 6.8.2 I've improved the speed of the lists that now will rely on the existing versions listed... so other accounts will rely on the existing one, that is outdated.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

This is why "AM" is for one system admin. Others can rely on the "AppMan mode".

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

at this point, to solve the problem of viewing the installed versions and files, it would be sufficient to keep /opt/am/.cache as the working directory, and make it editable by both admins and guests.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

I've just tested the downgrade to from "dev" to "main" using the guest user and worked! All modules are been restored to the version in "main" and were been managed in /opt/am/.cache

So the issue was the RW permissions of /opt/am/.cache

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

Also tried to use -s as "guest" in "Dev Mode" and got errors with chmod... but its normal, since "chmod" has not been silenced in "dev". All modules are now updated to the version available in "dev" anyway.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

Guest can't install anything... nor can update any installed app.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

Of corse, since I've update modules as guest from main to dev... the admin can't edit the modules, because the patch has not been implemented in APP-MANAGER from main... so now its all OK.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

So, its time to change the title of this PR.

@Samueru-sama we have solved the issue of permissions on multiple accounta without having to touch the "$HOME"./cache directory. The 6.3.3 nightmare is a far memory.

@ivan-hc ivan-hc changed the title Move ".cache" from "$AMPATH" to "$HOME" Change the permissions in "$AMPATH"/.cache so that it can be used by multiple accounts, privileged and otherwise, to update "AM" and its modules Jun 3, 2024
@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

As I already said, the guest user will not be able to install applications if he has no privileges. This is normal.

So the key point remains updating the apps, which is impossible if installed by a user other than the one who wants to update.

@Samueru-sama do you think it's a flaw?

I find it advantageous instead, in terms of safety. Strengthens the sense of the -b and -o combo, in terms of options.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

Strengthens the sense of the -b and -o combo, in terms of options.

This 👆

Now we have solved another issue in "-o" all of sudden

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

Even apps that update themselves refuse to update if you don't use them... I consider it a "loyalty reward"

Istantanea_2024-06-03_17-24-56 png

ivan-hc added 4 commits June 3, 2024 19:31
- give downloaded scripts and created directories the right privileges for common use in multiuser systems
- removed a non-essential function
Change permissions for all files and directories in /opt/am
@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

I've tested the installer too, in VM I had to replace "main" with "dev" in the URL, buth I've left the downloading of the modules from "Main". Steps I've done:

  • Login as admin, then install "AM";
  • Logout;
  • Login as "guest";
  • Performed some actions such as -f, -l, -s... no issues here.

So we have fixed this.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

In APP-MANAGER I had to specify the following command:

echo y | chmod 777 /opt/am /opt/am/* /opt/am/.cache /opt/am/modules 2>/dev/null
  • The command echo y | is needed because if /opt/am is managed by non-owners of the directory, we have a prompt to overwrite the files of the admin with ours;
  • Using chmod 777 to made /opt/am and all its files and directories editable for all users;
  • Finally 2>/dev/null is because non-privileged users can't use chmod 777 in /opt/am, so they get the error message.

@Samueru-sama I'm using this in all my VMs (Fedora 40, Debian and Arch Linux), and I'm testing this change on the Debian VM using three different accounts, two privileged and one not.

Of corse I'm using this right now on my main machine, in both AM and AppMan.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 3, 2024

At this point the "$CHACHEDIR" variable is unused.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

@Samueru-sama regarding the choice to call the variable "$AMCACHEDIR" instead of "$CACHEDIR", your variable is an excellent starting point for future implementations, I would leave it where it is. I like it the way it is. My variable instead is specific to a directory that has existed since the beginning of this project.

I just want to know if I need to add anything else or if it is possible to merge this PR as it is.

My test results are all posted, but if I missed something, I would really like your opinion on it before merging.

Also because you have just merged one of your PRs with "dev". In the case of apps to be merged, I would be more inclined to make these types of requests directly in "main", as they do not cause conflicts with the work done in the CLI.

I can't move forward without your confirmation.

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Jun 4, 2024

Also because you have just merged one of your PRs with "dev". In the case of apps to be merged, I would be more inclined to make these types of requests directly in "main", as they do not cause conflicts with the work done in the CLI.

Yeah I've been noticing lately that every PR I was making to dev was intermediately being merged to main.

I was doing it because I remember in one of my firsts PRs you told me to merge to dev instead. But ok from now on apps will go to main.


Regarding this PR, I guess everything is ready then.

if an app has been updated from another user, the version will appear not updated for another, this is because in 6.8.2 I've improved the speed of the lists that now will rely on the existing versions listed... so other accounts will rely on the existing one, that is outdated.

I see, other package managers like pacman use /var/cache/pacman for this kind of stuff. but if there is no problem with appman, then this is all ready!

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

I see, other package managers like pacman use /var/cache/pacman for this kind of stuff. but if there is no problem with appman, then this is all ready!

for example, I have "appman" in $HOME/.local/bin and all its files are in $HOME/.local/share/appman, this is why the option -f in "AM includes also "AM" and in AppMan does not includes it

Istantanea_2024-06-04_18-35-54 png

these are my directories of AM and AppMan instead

Istantanea_2024-06-04_18-37-13 png

as you can see, AppMan has not a "remove" script, this is because it is portable, so you can remove it by putting it in the thrash

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

@Samueru-sama I just want your opinion about file permissions in /opt/am

With the inclusion of the "AppMan" mode, any user could only manipulate the APP-MANAGER file.

With this change they can also manipulate forms and lists.

What do you think, does it matter?

I ask because a user who shares his system with other users, could have a really asshole user who could modify something maliciously.

Do you think this is a possible scenario?

Would you share your system with an asshole user?

PS: Regardless of who it is, if something like that were to happen to me... I'd break his legs. For sure.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

@Samueru-sama Last thing: this is a major change. How do you see it? From version 6.10 or from version 7?

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Jun 4, 2024

@Samueru-sama I just want your opinion about file permissions in /opt/am

With the inclusion of the "AppMan" mode, any user could only manipulate the APP-MANAGER file.

With this change they can also manipulate forms and lists.

What do you think, does it matter?

I ask because a user who shares his system with other users, could have a really asshole user who could modify something maliciously.

Do you think this is a possible scenario?

Would you share your system with an asshole user?

PS: Regardless of who it is, if something like that were to happen to me... I'd break his legs. For sure.

/opt (all of it) should be owned by the root user, and if you want to let the user use am without root password you allow them to do it by setting up a simple sudoers rule, which am itself can add.

This way also sudoers only allows the user to update and do nothing else for example.

Last thing: this is a major change. How do you see it? From version 6.10 or from version 7?

I don't think this is really that major, it's your call anyway.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

/opt (all of it) should be owned by the root user, and if you want to let the user use am without root password you allow them to do it by setting up a simple sudoers rule, which am itself can add.

But permissions are common only in /opt/am, not for other apps

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

However, the scenarios I outlined above do not appear to have occurred. It seems to me that Garuda Linux only has a "guest" account by default, but I could be wrong.

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Jun 4, 2024

/opt (all of it) should be owned by the root user, and if you want to let the user use am without root password you allow them to do it by setting up a simple sudoers rule, which am itself can add.

But permissions are common only in /opt/am, not for other apps

Ok Ivan I will tell you one thing, recently there was a big drama with hyprland because the developer made it so that it wrote some files for a few miliseconds to /tmp in a directory as it was compiling something for itself.

https://www.youtube.com/watch?v=BPo-Xa_J1yE

This created such a big drama, because it meant that another user could exploit that to insert malicious code, as hyprland was going to compile whatever was in /tmp which all users can write to.

If you ask me I think that drama was way overblown, but keep that in mind as it happen to us.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

What do you suggest we do?

Isn't using /opt/am /.cache or $HOME/.cache the same thing anyway? The modules and APP-MANAGER are always updated by any user. As for APP-MANAGER, this already happened in "AppMan Mode".

If we add it all up, the problem can be solved by preventing the use of "AppMan Mode" and allowing a single system administrator to use "AM", as before ex-6.3.3

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Jun 4, 2024

What do you suggest we do?

Leave am owned by the root user and require sudo to use it, add a function that adds the sudoers rule to allow to update without password and that is it.

However this cannot be done today or tomorrow, as we have to be careful to not push as breaking change like it happened before with the groups issue.

Isn't using /opt/am /.cache or $HOME/.cache the same thing anyway? The modules and APP-MANAGER are always updated by any user. As for APP-MANAGER, this already happened in "AppMan Mode".

No because, $HOME/.cache can only be written to by the user of said $HOME, I cannot edit the $HOME of other users for example.

If I'm not mistaken you said that /opt/am could be written to by multiple users, and that's a problem.

If we add it all up, the problem can be solved by preventing the use of "AppMan Mode" and allowing a single system administrator to use "AM", as before ex-6.3.3

I'm really don't understand what AppMan has to do here sorry 😅 AppMan is meant to be run in $HOME, so I don't know what it has to do in /opt.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

What do you suggest we do?

Leave am owned by the root user and require sudo to use it, add a function that adds the sudoers rule to allow to update without password and that is it.

However this cannot be done today or tomorrow, as we have to be careful to not push as breaking change like it happened before with the groups issue.

As long as "AppMan Mode" exists, it is not possible.

Isn't using /opt/am /.cache or $HOME/.cache the same thing anyway? The modules and APP-MANAGER are always updated by any user. As for APP-MANAGER, this already happened in "AppMan Mode".

No because, $HOME/.cache can only be written to by the user of said $HOME, I cannot edit the $HOME of other users for example.

I remind you of the versions issue https://github.com/ivan-hc/AM/releases/tag/6.8.2

If I'm not mistaken you said that /opt/am could be written to by multiple users, and that's a problem.

See "AppMan Mode"

If we add it all up, the problem can be solved by preventing the use of "AppMan Mode" and allowing a single system administrator to use "AM", as before ex-6.3.3

I'm really don't understand what AppMan has to do here sorry 😅 AppMan is meant to be run in $HOME, so I don't know what it has to do in /opt.

Have you ever tried to launch the command "am --user"?

Launch it, open the file APP-MANAGER and run the command am -s, and see if the file will not be updated.

APP-MANAGER is the only file of the "AM" installation involved in the "AppMan Mode". All other files are managed in the AppMan's dedicated directory, in your $HOME, included modules.

This PR basically allows the (almost) complete use of files installed with "AM" and for "AM".

That said, should I therefore close it definitively and completely close the "$CACHEDIR" discussion you proposed?

If yes, you agree with me when I tell you that "AM" must be managed by a single system administrator.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

I have another idea about this, to point out to the user that he doesn't have write permissions in the directories that "AM" manages, so he couldn't download at least the modules. It is already too late for APP-MANAGER, as this mechanism is used in "AppMan Mode".

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

I have another idea about this, to point out to the user that he doesn't have write permissions in the directories that "AM" manages, so he couldn't download at least the modules. It is already too late for APP-MANAGER, as this mechanism is used in "AppMan Mode".

as I did at a590ad4 with am -u $APPNAME

@Samueru-sama
Copy link
Contributor

As long as "AppMan Mode" exists, it is not possible.

You are telling me that on appman mode, AppMan doesn't write to AMPATH in $HOME?

Uh oh.

Have you ever tried to launch the command "am --user"?

I thought that change meant that you didn't have to rename APP-MANAGER to appman anymore and everything else still worked the same.

I don't use am. I only use appman. I don't even have sudo installed anymore and haven't bothered to test my recent PRs on am and I only do it in appman 😅


Also I don't understand what you changed exactly here, I thought you changed all instances of $AMPATH/.cache for a new $AMCACHEDIR variable, but it seems I didn't read the PR fully lol.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

Also I don't understand what you changed exactly here, I thought you changed all instances of $AMPATH/.cache for a new $AMCACHEDIR variable, but it seems I didn't read the PR fully lol.

In APP-MANAGER there is a series of confirmations on the chmod 777 command applied mainly in the steps related to downloading modules and general permissions in /opt/am

I think that at this point it is necessary to restore everything to its original state, changing only the ".cache" references... but I would add a message notifying that writing is impossible in some directories, as I did at a590ad4

@Samueru-sama
Copy link
Contributor

Also I don't understand what you changed exactly here, I thought you changed all instances of $AMPATH/.cache for a new $AMCACHEDIR variable, but it seems I didn't read the PR fully lol.

In APP-MANAGER there is a series of confirmations on the chmod 777 command applied mainly in the steps related to downloading modules and general permissions in /opt/am

I think that at this point it is necessary to restore everything to its original state, changing only the ".cache" references... but I would add a message notifying that writing is impossible in some directories, as I did at a590ad4

Btw Ivan I'm very sorry, like I wanted to do this in the near future and you intermediately began doing this and caught me off guard and couldn't help much.

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

Don't worry, I'll apply only the messages in APP-MANAGER and revert INSTALL to its original state.

@ivan-hc ivan-hc changed the title Multi-account support: changed permissions in /opt/am to update "AM" and its modules / check if apps are read-only (therefore not updateable by other users) Replace ".cache" references with the "$AMCACHEDIR" variable / added write control on installed app directories / conversion in functions of the processes to update apps and generate the options list Jun 4, 2024
@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

In the end, this PR turned into a simple refactoring with the addition of a couple of apps.

At least we have explored the discussion on permits. At this point I can also close the discussion as https://github.com/ivan-hc/AM/discussions/616

@ivan-hc ivan-hc merged commit a9a9a38 into main Jun 4, 2024
9 checks passed
@ivan-hc ivan-hc deleted the dev branch June 4, 2024 20:26
@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

@Samueru-sama I have to recalibrate the shot, it is not possible to update APP-MANAGER from other accounts. So "AM" is safer than we thought.

I would just like to find a way to avoid this crap in other accounts:

Istantanea_2024-06-04_22-40-07 png

@ivan-hc
Copy link
Owner Author

ivan-hc commented Jun 4, 2024

It is a problem that sooner or later we will have to face, leaving the rule "AM has only one admin" intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants