14 ms·
Show HN: boxxy – Control where Linux programs put files, without symlinks
- fezzez 4y agoThis looks really convenient
- vippy 4y agoOk, hi! My name is Boxxy...
- userbinator 4y agoThat brings back memories... of an era of Internet that many here are probably too young to have experienced.
- Insanity 4y agoI wonder what the demographic for HN looks like. I never questioned how much younger the audience would be than me (and I definitely remember Boxxy and the related internet/4chan drama).
- RamblingCTO 4y agoI'd think the demographics are more 30+ and thus do probably remember the 4chan stuff.
- Insanity 4y agoYup, that was my assumption as well!
- swozey 4y agoHN is predominately older millennials and genx. This site isn't really making waves among the "kids" and I doubt ever will unfortunately. It's us taking this ship to its end. o7 I would like to see the ages and sign up numbers over the years.
- fsckboy 4y agoI don't know if it's making waves among the zoomers, but there isn't yet an alternative for zoomers who've entered the tech workforce, is there?
- swozey 4y agoAll the techy ones are on discord nowadays, it's the modern IRC. My go and rust servers are packed with people half my age (late 30s).
- cheapliquor 4y agoYOU'S TROLLIN' I'S NOT TROLLIN I AM BOXXY YOU SEE ^_^
- sodapopcan 4y agoTROOOLUH TROOOLUH uhmmm... uh.... TROOOLUH TROOOLUH BEATLES TROOOLUH TROOOLUG he, like, remixed buh buh buh BUUUUUHHHH
- RamblingCTO 4y agoGod, that title sent me down memory lane https://www.youtube.com/watch?v=6bMLrA_0O5I https://www.youtube.com/watch?v=6bMLrA_0O5I
- fsckboy 4y agoand then that day when the stars aligned and Boxxy met the Overly Attached Girlfriend https://www.rouming.cz/archived/boxxy_overly_attached_girlfriend.jpg https://www.rouming.cz/archived/boxxy_overly_attached_girlfr... my favorite Boxxy autotune remix is this one https://www.youtube.com/watch?v=7Q7cqT3BiOI https://www.youtube.com/watch?v=7Q7cqT3BiOI
- sammalloy 4y agoBoxxy and Laina? Might need to get that framed.
- bpiche 4y agoour screamo queen, glad to see this here
- flangola7 4y agoShe's on regular TV now IIRC
- sergiotapia 4y agomy queen, i kneel.
- ghc 4y agoOh, god...I'm old now :(
- deleted 4y ago[deleted]
- smcl 4y agoVery glad I'm not the only one who thought of this :)
- whalesalad 4y agoIs this named after the one and only boxxy?!
- notamy 4y agoNo! I just thought it was a cute name ("put things in a box"), and it wasn't a common repo name on GitHub.
- sosodev 4y agoYou might be surprised how many of us were obsessed with Boxxy lol.
- ravenstine 4y agoGlad someone still remembers the e-drama of yore. I wasn't obsessed with Boxxy, but that's a name that reminds me of the glory days of the internet.
- trallnag 4y agoI actually think it was just you obsessing over her unironically
- notamy 4y agoI remember it quite well! Just not my particular cup of tea.
- warent 4y agoYUP, she was the OG camgirl, sadly got all the worst parts of the gross attention / fame without any of the perks/money that Belle Delphine gets now
- Gare 4y agoAt least it seems she's doing okay. Money, fame and attention can ruin lives, especially if obtained at a young age.
- 4y ago
- adhoc_slime 4y agoHah I was literally just complaining about applications not following the XDG directory spec today. there's a non-exhaustive list of applications on the archwiki [0] that put their config/data in dotfiles in the home directory. surprisingly, there's also lots of pushback from maintainers of projects who don't want to change this, for whatever excuse they can produce. a Reddit thread has some list of issues where the change is brought up [1]. Anyway, I'll look forward to testing this out. [0] https://wiki.archlinux.org/title/XDG_Base_Directory https://wiki.archlinux.org/title/XDG_Base_Directory [1] https://www.reddit.com/r/linux/comments/971m0z/im_tired_of_folders_littering_my_home_directory/ https://www.reddit.com/r/linux/comments/971m0z/im_tired_of_f...
- NoboruWataya 4y agoYep, this does my head in. I really feel like there's no excuse for it in 2023.
- inanutshellus 4y agoCan I also soapbox about the XDG_CONFIG_HOME (~/.config) folder having gigs of temp data in it? (I'm looking at you, Slack!) How awesome would it be to be able to back up my custom app configs just by copying around one tiny folder? Or throwing it in a git repo and knowing what config changed when? :\
- vngzs 4y ago$ du -sch ~/.config/Slack 846M $HOME/.config/Slack 846M total ... this is on a two day old machine. WTF, Slack? Junk cached data belongs in ~/.local/share ($XDG_DATA_HOME), not ~/.config.
- deadbunny 4y agoI think you mean `~/.cache`.
- Already__Taken 4y agoa bunch of windows stuff does this too putting config in appdata/local and huge cache assets in appdata/roaming. anything that depends on good behaviour is doomed imo like Google wave circles
- oneplane 4y agoAWS an interesting example considering it's also a default search path for the SDK so anything using an AWS SDK is going to check for ~/.aws/config; does boxxy apply the rules to anything run in a shell, or only if 'run by boxxy'?
- notamy 4y agoOnly in the latter case; I didn't want to assume how people want things done, and implicitly magical tools break more often than not in my experience. You may also be able to tell I don't have a lot of AWS experience (:
- bheadmaster 4y agoWould be cool if there was a tool that could detect that configured path was attempted to be opened, and redirect the open() syscall to the real path... But that would most likely require kernel support. Boxxy seems good enough for userspace.
- notamy 4y agoI actually attempted using ptrace to rewrite syscalls first! It was... horribly painful, and didn't work anywhere near as well as the bind-mount version.
- oneplane 4y agoIn the past I used something like inotab to use an inotify-based trigger to pipe data from SSH to a different system that didn't have any NAS or SAN support, it might also work to detect 'who' is touching any files that boxxy has previously seen rules for. Perhaps still too tricky to make it do magic things and break programs in the process, but it could be used to audit who's working with what paths and let the user print a report so they know what apps to boxx up and make them behave.
- notamy 4y ago
- Zurrrrr 4y agoThis is nice. This is why I like to use minimal distros like Alpine or Void, so I know where everything is on my system and have some control over it.
- nyanpasu64 4y agoDoes this use namespaces or chroot? The readme mentions namespaces (like Flatpak?), but https://github.com/queer/boxxy/blob/mistress/src/enclosure/mod.rs https://github.com/queer/boxxy/blob/mistress/src/enclosure/m... seems to indicate it uses chroot.
- notamy 4y agoIt creates a new mount namespace, and bind-mounts your ENTIRE filesystem into it, before chrooting, so that it can optionally remount / as ro to prevent applications from writing outside of the desired directories. The namespace is to allow doing the bind mounts in the first place.
- sureglymop 4y agoThis is awesome!! Good stuff
- iamdamian 4y agoThis seems like a great idea, thank you for sharing. Are you aware of any notable caveats to using Boxxy, given the mount-based implementation? E.g., will this continue to work if you sync ~/ with other machines (rsync, FTP, SyncThing)?
- notamy 4y ago> This seems like a great idea, thank you for sharing. Thanks :D > Are you aware of any notable caveats to using Boxxy, given the mount-based implementation? System configuration to allow mount namespaces, tools might have to understand recursive paths, it's tested for my use-cases. > E.g., will this continue to work if you sync ~/ with other machines (rsync, FTP, SyncThing)? I haven't tried it! Would love to see what happens as that's unfortunately not a use-case I have.
- TechBro8615 4y agoIn my experience doing weird things with mountpoints, there is almost always some bug that happens on reboot of the system. For example, if your mounts aren't in /etc/fstab, they simply won't be restored. And if you have a script that sets them up manually, then make sure that script runs on boot after any mounts it implicitly depends on. Also note that any scripts with config stored in these mountpoints (which seems to be the point of the tool) will not be able to run until the mountpoints are up. That seems like an obvious observation, but it's easy to fall into a trap where one of your scripts installed with this tool is called in a setup script that runs on boot of your machine.
- deleted 4y ago[deleted]
- notamy 4y agoYes, absolutely! Good points to be aware of; I should find a way to add some warnings about this to the README. (earlier less-relevant comment was deleted)
- bullfightonmars 4y agoThis is very cool and would massively simplify how I build my dotfiles. Is there any way this could support macOS?
- notamy 4y ago> Is there any way this could support macOS? I don't use macOS often-enough to know for sure, but a quick search suggests that bind-mounts (or similar) are more complicated on macOS. Not against the idea tho! Edit: > and would massively simplify how I build my dotfiles. I guess I should tell r/unixporn at some point, huh? (:
- marssaxman 4y agoI wonder if this could be used to move the obnoxious ~/snap directory.
- JosephRedfern 4y agoI was wondering the same. So infuriatingly obnoxious!
- stabbles 4y agoQuestion is if those user/mount namespace tricks are composable
- notamy 4y agoAs far as I'm aware, yes! You should be able to nest namespaces and mounts.
- suyula 4y agoWhile reading more about this I found out about the ~/.hidden file which I'm pretty excited about. The following hides the folder from Thunar & Dolphin (and presumably other file managers): echo snap >> ~/.hidden
- forgotpwd16 4y agoBut sadly `ls ~` will still show it.
- deleted 4y ago[deleted]
- yesco 4y agoI'd been meaning to make something like this for ages but never had the patience to figure out the namespace API, great work!
- notamy 4y agoThanks :D <3
- pshirshov 4y agoIt would be very nice to integrate it with Nix and make the hijacking automatic (perhaps with LD_LIBRARY_PATH).
- pipeline_peak 4y ago.
- notamy 4y ago*she, but thanks! (:
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- arberx 4y agoWhats the difference between this and a chroot?
- notamy 4y agoInstead of chrooting to somewhere else, replicating your filesystem, ..., this switches into a new mount namespace and uses bind mounts to shadow the files/directories that are intended to be redirected. This way your entire filesystem continues to be visible to the target application, and only the paths you want altered are altered.
- nmstoker 4y agoMaybe I've misunderstood, but it seems like this would only help for files the program puts in places itself. Thus it wouldn't help with files placed by the installer would it?
- hdjjhhvvhga 4y agoIt looks like a useful project. By the way, as for the original motivation: > I recently had to use the AWS CLI. It wants to save data in ~/.aws, but I don't want it to just clutter up my $HOME however it wants. boxxy lets me force it to puts its data somewhere nice and proper. - they could have used AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE.
- notamy 4y agoTIL! Thanks :D
- jxf 4y agoBut you shouldn't have to — that's the point of the complaint. That's like saying that if your neighbor is dumping toxic waste in your yard, you can always ask them to stop. Sure, but maybe they just shouldn't do that in the first place.
- hdjjhhvvhga 4y agoSure. But there will be many scenarios where you can't use boxxy.
- deleted 4y ago[deleted]
- boomskats 4y agoIsn't this what your `~/.config` directory is for? Is that where you'd expect it to try first? Really interesting project for other use cases too btw.
- notamy 4y agoIt is, but I find many programs ignore ~/.config 3:
- jpeeler 4y agoCan boxxy make use of rules with regex? If not, consider this a feature request.
- notamy 4y agoIt sadly can't. Regex paths are hard due to the way it's implemented; if it was intercepting syscalls via ptrace then regex would be a lot more viable, but since this is just a glorified collection of bind mounts in the end, I'm unsure how I'd implement that nicely...
- ossusermivami 4y agonice idea but tmux may not be the right example for the readme example since tmux actually supports XDG and its config in ~/.config/tmux/tmux.conf
- notamy 4y agoTIL! I guess I'll find a better example.
- acdw 4y agoI humbly submit either bash, sh, or zsh --- they all put dotfiles in $HOME that you can't move (zsh technically /can/, but they're still dotfiles and you have to set them in ~/.zshenv). Very annoying IMO. Course, might not work so well with the way boxxy is run ... unless you chsh to boxxy bash or something.
- 149765 4y agoIt's possible to set $ZDOTDIR in /etc/zsh/zshenv, I used to do it before switching to fish.
- nikau 4y agoIf only files and directories starting with a dot were hidden from view
- frebdo 4y ago[flagged]
- gnull 4y agoChromium doesn't respect XDG config, it always creates ~/Downloads directory on startup. It was so annoying, I hope this tool helps me fix it.
- forgotpwd16 4y agoMaybe change download location in chrome://settings/downloads to where you want?
- gnull 4y agoI did. It still creates an empty ~/Downloads on each startup.
- gnull 4y agoUpdate: the tool didn't help. It complains about being unable to run some SUID executable that Chromium calls. I'll have to keep removing the Downloads by hand then after each use of Chromium.
- jwilk 4y agoAFAICS it does respect https://www.freedesktop.org/wiki/Software/xdg-user-dirs/ https://www.freedesktop.org/wiki/Software/xdg-user-dirs/.
- gnull 4y agoI'm not using default settings, I changed XDG downloads setting in ~/.config/user-dirs.dirs.
- 29athrowaway 4y agoAmazing, I will use this for sure. My home directory is a mess.
- inamberclad 4y agoYep, have an old Java application that wants to put calibration data for a vector network analyzer right in my home directory. This is a perfect tool.
- iuafhiuah 4y agoAnother solution might be to override the root user directory like: _JAVA_OPTIONS="-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/programName" programName
- ameminator 4y agoWho knew that the phenomenon that launched 1000 Low Orbit Ion Canons would return to help with my Linux installs.
- deleted 4y ago[deleted]
- OJFord 4y ago> suggested usage > alias aws="boxxy aws" (repeat for other tools) If you could find a way to somehow intercept without requiring aliasing, this would be amazing. Also, as it is, isn't it problematic that programs might call others (outside of your shell, not respecting its aliasing). A neat semi-solution (still worse than transparent interception if somehow possible) would be to have a boxxy-run script sym-linkable from ~/whatever/bin/aws (say) that basically just executes `boxxy "$(basename "$0")"`. So you could just symlink the same script with the name of whatever command you wanted to 'boxx'.
- chungy 4y agoI mean, you can just run "boxxy aws" if you don't want to make an alias. That's your solution for "intercept without requiring aliasing" As the program intercepts file APIs for all processes launched under it, it should handle subprocesses just fine.
- OJFord 4y agoNo I mean as in if I run foobar, which itself happens to call aws under the hood. Now I need both boxxy foobar and boxxy aws configured for the same ~/.aws redirection.
- alerighi 4y agoPerhaps a better solution would have been not using the Linux namespaces but using LD_PRELOAD to preload a shared library to intercept all the FS-related API and normalize the path. Of course more complex and would only function for dynamically linked executables, but would have not required to launch the executable with a proxy and would also be more stable, not relying on not so stable features such as Linux namespaces.
- notamy 4y ago> If you could find a way to somehow intercept without requiring aliasing, this would be amazing. I figured out while testing that `boxxy sh` works as expected, so I would imagine you can wrap any shell in it since it’s just a mount namespace. > Also, as it is, isn't it problematic that programs might call others (outside of your shell, not respecting its aliasing). Nope! Any spawned processes live inside the same mount namespace and see the same pretend view of the world.
- pjdkoch 4y agoI was expecting LD_PRELOAD trickery.
- doodlesdev 4y agoIf anyone would like to actually force the non-compliant applications to do the thing correctly, then xdg-ninja is your friend [0]. The script looks at all the dotfiles in the home folder and tells you what environment variables you have to set to make them follow XDG base directory specifications, in the cases where that's not possible it will show you the related GitHub issue or similar bug tracking option with the problem. My current dotfiles [1] already have a lot of these and they mostly just work. Once in a while an application won't respect it completely, and so instead of having a mess with xdg + whatever the dev though was cooler I just let the application do it's thing so at least is somewhat predictable. [0]: https://github.com/b3nj5m1n/xdg-ninja https://github.com/b3nj5m1n/xdg-ninja [1]: https://github.com/DoodlesEpic/Dotfiles/blob/main/.profile https://github.com/DoodlesEpic/Dotfiles/blob/main/.profile
- thejosh 4y agoThis is fantastic! Thanks for the share. Reminds me of lostfiles for Arch. https://man.archlinux.org/man/community/lostfiles/lostfiles.1.en https://man.archlinux.org/man/community/lostfiles/lostfiles.... Was thinking this would be a useful tool, same as a tool that would show you where environment variables are being set, and which ones override what.
- gdprrrr 4y agoIt also has a table of applications docunented https://wiki.archlinux.org/title/XDG_Base_Directory https://wiki.archlinux.org/title/XDG_Base_Directory
- evanpurkhiser 4y agoI have a similar list in my bashrc [0]. I didn't know about xdg-ninja though, thank you! [0]: https://github.com/evanpurkhiser/dots-personal/blob/main/base/bash/environment https://github.com/evanpurkhiser/dots-personal/blob/main/bas...
- klntsky 4y agoDoes it use a centralized database of all known software?
- winrid 4y agoThis person actually has a lot of interesting projects!
- notamy 4y agoAww, thank you!
- superluserdo 4y agoPlug: I made a small set of shell scripts to achieve something similar to this a couple of years ago, but with symlinks: https://tomwh.uk/blog/posts/2020/03/28/fake-home-prison/ https://tomwh.uk/blog/posts/2020/03/28/fake-home-prison/ https://tomwh.uk/git/fake-home.git/ https://tomwh.uk/git/fake-home.git/ It's a simple command that shadows the binary names you want with a wrapper in ~/.local/bin/ that calls the original binary after redefining $HOME to be somewhere else (by default inside ~/.local/share/fake-home/). So if you have a program foo that dumps stuff in ~/.foo, then running `fakehome-banish foo` will create a symlink "foo" inside ~/.local/bin/evil-software (which is added to $PATH) that points to "fakehome". "fakehome" is a simple wrapper script that, busybox-style, gets the binary name that it's being called as ("foo"), and then sets $HOME to be ~/.local/share/fakehome and calls the original foo binary.
- fsckboy 4y agoI hate when applications ignore the XDG spec, but you know what I hate more? the XDG spec! I don't want all my pictures to go in Pictures, all my documents in Documents, etc. I want everything from each project to go in the directory for that project. I don't need it to read my mind, but when I save a document to a new directory and then I want to save a spreadsheet too... I want that new directory to be a top-line choice, but I want the old directory there too. Doesn't everybody work like me? (asking seriously) and hey, call me a freak, but I still get the odd sort of picture that I don't want showing up on the lock screen screensaver
- account42 4y agoI don't think there is a spec dictating that the default location for saving files needs to depend on the file tile - which program is doing this? I think Firefox remembers the last used path per file type, even across restarts. The Desktop, Downloads, Pictures, etc. directories themselves are not from the XDG Basedir spec and not set by XDG_ environment variables but instead in the $XDG_CONFIG_HOME/user-dirs.dirs file. I also find these less useful than the more generel data/config/cache dirs and have most theme set to my home directory - perhaps that is affecting how Firefox works?
- its-summertime 4y agohypothetical, but, could easily make a script that, upon cd, checks all above directories for `.xdg-root`, and while inside, has envvars set to use said folder as a root for Documents/Pictures/Etc folders
- fsckboy 4y agonot a terrible idea, has some good points, but gui apps don't cd in a way that can be hooked, and usually i get around to popping a terminal window after i'm working on a project rather than before. (also, cd isn't so easy to script, I'd have to use a bash function, but i'd probs have to make a up new name to get used to, cdproj or something, otherwise any "headless" scripts would be do it too And I frequently jump from desktop to desktop for multiple projects, and my terminal on that desktop is likely to already be where I want to be. Do gui apps reliably reload xdg all the time, or only at startup? anyway, keeping it in mind, it might just be worth the trouble to click a scripted icon on each desktop :)
- cdelsolar 4y agoOmg boxxy???
- Hello71 4y agobut... if you use unprivileged user namespaces, tmux isn't a very good use, because then you can't use any suid programs like su, sudo, doas, pkexec, fusermount, mount (user), etc.
- jzombie 4y agoHow does this differ from containers?
- jzombie 4y agoInteresting someone could downvote this question without at least giving a response.
- japanman425 4y agoHi my name is boxxy
- patmcc 4y agoThis is neat! What's so bad about symlinks though?
- notamy 4y ago> What's so bad about symlinks though? I am not smart and will regularly forget the syntax to ln(1)
- efreak 4y agoEasy solution for that is what I do, just cd to the directory you want the symlink placed in, and then create it with one path instead of two. No need to think about whether or not the order is correct. It's really obnoxious that Windows chose the opposite syntax. (Yes. I have an unnecessary number of junction points and hard links on my system. When I reinstall next, I'll have a bad time dealing with it) `mklink [[/d] | [/h] | [/j]] <link> <target>` `ln [OPTION]... [-T] TARGET LINK_NAME`
- colinsane 4y agoi was using a similar bind-mount trick as Boxxy for a good 6 months or so, and then reworked it to prefer symlinks a couple months ago. nearly everything behaves as you’d expect with symlinks if you’re just symlinking within ~, and it’s easier to tell what’s going on or debug stuff. notably, at some point i decided to encrypt my valuables: password store, PII, etc, and have them unlocked on login via PAM. i also wanted these to be locked when i lock my session. if you have, say, a ~/private mountpoint with sensitive stuff, and then ~/.password-store (for your password manager) pointing somewhere into this store, 2 things can happen when you `umount ~/private` 1. if ~/.password-store was a bind mount over ~/private/, your decrypted passwords will still be accessible through ~/.password-store. 2. if ~/.password-store was a symlink into ~/private/, then your passwords aren’t accessible. chances are you wanted (2), and it might be scary when you discover that’s not what you had, months after setting it up… i’ve also had some nasty mount duplication, where some cron job bind-mounts the same thing every hour. turns out linux will happily let you create identical bind mounts as many times as you want, until `/proc/mounts` has 2000 entries and some O(n^2) behavior somewhere in systemd’s namespace setup makes `systemctl start foo` take 3 minutes before invoking any service code. that was a PITA to figure out. the worst thing that happens when you “mount” the same thing twice when using symlinks, on the other hand, is you get some very obvious nesting. so anyway, i’ve bit myself a few too many times. i’m very weary to reach for bind mounts anywhere symlinks can also do the job.
- __turbobrew__ 4y agoCan you use boxxy on itself if you dont want the config file at ~/.config/boxxy/boxxy.yaml ?
- etu 4y agoI would assume that it follows the XDG spec and that you can specify XDG_CONFIG_HOME to place the file somewhere else.
- deleted 4y ago[deleted]
- intsunny 4y agoI remember when the GNUStep people thought their software was important enough to create `~/GNUStep`. Fucking maddening. Especially when one did not actually use GNUStep but some dependency.
- account42 4y agoThere have been some bad ports of Windows games creating ~/My Documents lol. AFAIK there's also ~/snap. You'd think at least such non-hidden hardcoded directories would bother the developers themselves.
- Jorengarenar 4y agoOh, the logic behind the excused for ~/snap made me never want to use that program at all
- royjacobs 4y agoThis is pretty cool! It's surprising to see the project be at version 0.2.5 when the first commit was _yesterday_ though. What's the reason behind cutting this many releases?
- notamy 4y agoI cut releases as I find bugs and commit fixes.
- solatic 4y agoThe biggest problem with getting programs to respect the XDG spec isn't getting programs to move their config file from $HOME/.myproj.yaml to $HOME/.config/myproj/config.yaml. It's getting projects not to store configuration and secrets in the same file. So much for checking all of $HOME/.config into a Git repository.