avfs icon indicating copy to clipboard operation
avfs copied to clipboard

IDM on Plan 9 / Windows

Open schmidtw opened this issue 3 months ago • 4 comments

The general avfs is great. However, the IDM bit is problematic. As written, it can't support Windows / Plan 9 since it's uid/gid are strings and not numbers. https://pkg.go.dev/os/user#User

I propose that the design change to align with what go has done so this can "just work" on Windows / Plan 9 types of systems. Otherwise, I fear this will cause folks to fork/ignore. For example I often need to support linux/windows/macos & will be forced to make that kind of decision.

schmidtw avatar Oct 12 '25 21:10 schmidtw

If you're willing to drop the support for group/user management, that will greatly simplify this library and make it less brittle. Each different OS/system (even between linux versions there are differences) for most of these calls:

func (idm *OsIdm) AddGroup(groupName string) (avfs.GroupReader, error)
func (idm *OsIdm) DelGroup(groupName string) error
func (idm *OsIdm) AddUser(userName, groupName string) (avfs.UserReader, error)
func (idm *OsIdm) DelUser(userName string) error
func (idm *OsIdm) AddUserToGroup(userName, groupName string) error
func (idm *OsIdm) DelUserFromGroup(userName, groupName string) error
func (idm *OsIdm) SetUserPrimaryGroup(userName, groupName string) error

If removing this is ok, it also means we don't need to mess around with Admin/root or knowing what underlying OS we're dealing with in this library.

I'm working on trying to get the IDM working everywhere for my needs now & can propose a prototype of this shortly if you're amenable to the idea.

schmidtw avatar Oct 13 '25 01:10 schmidtw

These functions are only useful for Linux / macOS, and only for testing file permissions. These tests are used by MemFS / MemIdm to replicate this behavior. I totally understand that there are not of any usage in a production environment, and by default, OsFS uses DummyIdm which, as its name implies, does not execute anything in any of these functions. As of today, everything is not documented properly, and the whole project is a work in progress. I will perhaps have some time to work on it by the end of the week. Knowing these constraints, if you have any ideas to get rid of these functions, feel free to expose them.

psadac avatar Oct 15 '25 09:10 psadac

I forgot to address Windows / Plan9 support :

  • for testing permissions you can't use os/user since it uses some kind of cache.
  • Creating users and switching between them on Windows is much more complex than doing this on Linux,
  • Plan9 does not have a runner on github.
  • that's why i used ints for UID/GID
  • however if you don't need to replicate permission behavior you can still use this library on these OSes.

psadac avatar Oct 15 '25 11:10 psadac

Thanks for responding. I'm going to read over things again & also re-evaluate the direction I was heading. I hope to get to spend some time exploring this more as well.

schmidtw avatar Oct 18 '25 01:10 schmidtw