---
name: "mutt_dotlock"
section: "1"
platform: "linux"
package: "mutt"
version: "2.2.13-1+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mutt_dotlock"
---

# mutt\_dotlock(1)

Lock mail spool files.

## NAME

mutt\_dotlock - Lock mail spool files.

## SYNOPSIS

**mutt\_dotlock** \[-t\|-f\|-u\|-d\] \[-p\] \[-r *retries*\] *file*

## DESCRIPTION

**mutt\_dotlock** implements the traditional mail spool file locking method: To lock *file*, a file named *file*.lock is created. The program operates with group mail privileges if necessary.

## OPTIONS

- \-t

  Just try. **mutt\_dotlock** won't actually lock a file, but inform the invoking process if it's at all possible to lock *file*.

- \-f

  Force the lock.  If another process holds a lock on *file* longer than a certain amount of time,  **mutt\_dotlock** will break that lock by removing the lockfile.

- \-u

  Unlock. **mutt\_dotlock** will remove *file*.lock.

- \-d

  Delete. **mutt\_dotlock** will lock *file*, remove it if it has length 0, and afterwards remove *file*.lock.

- \-p

  Use privileges.  If given this option,  **mutt\_dotlock** will operate with group mail privileges when creating and deleting lock files.

- \-r *retries*

  This command line option tells  **mutt\_dotlock** to try locking *retries* times before giving up or (if invoked with the  **-f** command line option) break a lock.  The default value is 5. **mutt\_dotlock** waits one second between successive locking attempts.

## FILES

- *file*.lock

  The lock file  **mutt\_dotlock** generates.

## SEE ALSO

[**fcntl**(2)](/fcntl/2.md), [**flock**(2)](/flock/2.md), [**lockfile**(1)](/lockfile/1.md), [**mutt**(1)](/mutt/1.md)

## DIAGNOSTICS

**mutt\_dotlock** gives all diagnostics in its return values:

- **0 - DL\_EX\_OK**

  The program was successful.

- **1 - DL\_EX\_ERROR**

  An unspecified error such as bad command line parameters, lack of system memory and the like has occurred.

- **3 - DL\_EX\_EXIST**

  The  user wants to lock a file which has been locked by another process already.  If  **mutt\_dotlock** is invoked with the **-f** command line option,  **mutt\_dotlock** won't generate this error, but break other processes' locks.

- **4 - DL\_EX\_NEED\_RPIVS**

  This return value only occurs if  **mutt\_dotlock** has been invoked with the  **-t** command line option.  It means that **mutt\_dotlock** will have to use its group mail privileges to lock *file*.

- **5 - DL\_EX\_IMPOSSIBLE**

  This return value only occurs if **mutt\_dotlock** has been invoked with the **-t** command line option.  It means that **mutt\_dotlock** is unable to lock *file* even with group mail privileges.

## NOTES

**mutt\_dotlock** tries to implement an NFS-safe dotlocking method which was borrowed from  **lockfile** (1).

If the user can't open *file* for reading with his normal privileges,  **mutt\_dotlock** will return the **DL\_EX\_ERROR** exit value to avoid certain attacks against other users' spool files. The code carefully avoids race conditions when checking permissions; for details of all this see the comments in dotlock.c.

## HISTORY

**mutt\_dotlock** is part of the Mutt mail user agent package.  It has been created to avoid running mutt with group mail privileges.

## AUTHOR

Thomas Roessler \<roessler@does-not-exist.org\>
