dotlock(1)

πŸ“¦
version 0.57 Β· 3 versions
, in nixos 26.05, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– dotlock(1) πŸ’–

okay bestie, pull up a chair, we're talking about lbdb_dotlock β€” the little Unix manual that lives in User Manuals, section 1. yes it's giving "ancient mail server energy" but honestly? it's iconic. let's go. πŸŽ€


✨ NAME ✨

lbdb_dotlock β€” lock mail spool files. that's it. that's the job. protect the spool, protect the vibe. πŸ’…


✨ SYNOPSIS ✨

lbdb_dotlock [-t|-f|-u|-d] [-r retries] file

so it's lbdb_dotlock, then ONE of -t, -f, -u or -d (pick a lane, bestie πŸ’€), then optionally -r retries if you're feeling spicy, and then the file you're doing all this to. periodt.


✨ DESCRIPTION ✨

so basically, dotlock is out here implementing the traditional mail spool file locking method. the whole trick is lowkey elegant: to lock file, it creates a file called file.lock. that's the entire personality. one file begets another file. slay. ✨


✨ OPTIONS ✨

  • -t β€” just try. dotlock won't actually lock the file, it'll just tell the invoking process whether locking file is even possible at all. it's giving "hypothetically, could we?" πŸ¦‹
  • -f β€” force the lock. if some other process has been holding a lock on file for longer than a certain amount of time, dotlock will break that lock by removing the lockfile. ruthless. no cap. πŸ’€
  • -u β€” unlock. dotlock removes file.lock. bye bestie πŸ‘‹
  • -d β€” delete. dotlock locks file, removes it if it has length 0, and afterwards removes file.lock. multi-step main character behavior 🌟
  • -r retries β€” this one tells dotlock to try locking retries times before giving up, or β€” if it was invoked with the -f command line option β€” before breaking a lock. the default value is 5. and between each successive locking attempt, dotlock waits one second. patience is a virtue, i guess 🧚

✨ FILES ✨

  • file.lock β€” the lock file that dotlock generates. it's the whole point. the moment. the icon. πŸ‘‘

✨ SEE ALSO ✨

fcntl(2), flock(2), lockfile(1), lbdb-fetchaddr(1) β€” go read those too, i'm not gatekeeping 🫢


✨ DIAGNOSTICS ✨

dotlock gives all its diagnostics in its return values, so like, watch the exit code, bestie:

  1. 0 - DL_EX_OK β€” the program was successful. we love to see it. πŸŽ‰
  2. 1 - DL_EX_ERROR β€” an unspecified error happened, like bad command line parameters, not enough system memory, that kind of thing. it's giving chaos 😭
  3. 3 - DL_EX_EXIST β€” the user wants to lock a file that some other process has already locked. BUT if dotlock was invoked with the -f command line option, it won't generate this error β€” instead it'll break those other processes' locks. bold. πŸ”₯
  4. 4 - DL_EX_NEED_RPIVS β€” this return value only shows up if dotlock was invoked with the -t command line option. it means dotlock is gonna have to use its group mail privileges to lock file.
  5. 5 - DL_EX_IMPOSSIBLE β€” this return value also only shows up with the -t command line option. it means dotlock is straight up unable to lock file. rip. πŸ’€

✨ NOTES ✨

dotlock tries to implement an NFS-safe dotlocking method, which was borrowed from lockfile(1). we love a collab. 🀝

⚠️ okay this part matters: if the user can't open file for reading with their normal privileges, dotlock will return the DL_EX_ERROR exit value β€” and that's on purpose, to avoid certain attacks against other users' spool files. the code carefully avoids race conditions when checking permissions; for all the gory details, see the comments in dotlock.c. πŸ•΅οΈβ™€οΈ

✨ HISTORY ✨

dotlock is part of the Mutt mail user agent package. it was created to avoid running mutt with group mail privileges. a humble origin story honestly 🌸


✨ AUTHOR ✨

Thomas Roessler <roessler@guug.de> β€” ty king 🫑


and that's the whole page, bestie!! this one came from Unix, dated JANUARY 2016 πŸ’œ so yeah, shoutout to that source and that date, they're literally the whole footer energy. now go lock your spool files responsibly. mwah πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from