How Unrar Handles Named Pipes and Block Devices

This article explains how the unrar utility processes special Unix file types, specifically named pipes (FIFOs) and block devices, during archive extraction. While standard Unix archiving tools like tar preserve system-specific special nodes, unrar handles them differently due to format limitations, portability constraints, and operating system security safeguards.

Default Archive and Extraction Support

The official unrar utility (maintained by RARLAB) does not support the creation or extraction of block devices, character devices, or named pipes. The RAR format is designed primarily as a cross-platform data compression standard rather than a low-level Unix system backup tool.

When extracting an archive:

  • Symbolic and Hard Links: Modern versions of unrar can extract symbolic and hard links on Unix-like operating systems if the appropriate command-line flags (such as -ol) are specified.
  • Named Pipes (FIFOs): unrar contains no internal routines to call mkfifo(). If a FIFO was somehow encapsulated into a RAR archive, unrar does not reconstruct it as a special pipe node.
  • Block Devices: unrar does not invoke mknod() to recreate device nodes (such as disk drives or partitions).

How unrar Treats Special Nodes

If you attempt to extract an archive that references or attempts to mimic special system files, unrar behaves in one of the following ways:

  1. Skipping Unsupported Entries: If the archive header specifies an unsupported or unrecognized file type, unrar typically skips the entry entirely, outputting an extraction warning or error to the terminal.
  2. Extraction as Regular Files: If the archive tool that generated the RAR file read the special file as a stream (such as reading from a device or pipe at the time of archiving), unrar simply sees standard file data. It will extract this data as a normal, regular file rather than recreating the device node or pipe.

Security and Operating System Restrictions

The lack of device node recreation in unrar also serves as a crucial security safeguard:

  • Privilege Requirements: Creating block or character devices on modern Unix systems requires elevated privileges (the CAP_MKNOD capability, typically restricted to root). Regular users cannot create device nodes.
  • Attack Prevention: Allowing an unarchiving tool to create arbitrary block devices could lead to severe security vulnerabilities, such as a malicious archive creating direct interfaces to physical storage or memory without the administrator's knowledge.

To store and extract named pipes, block devices, or other special filesystem nodes, package the items using tar first, which natively supports special device metadata via standard POSIX headers:

# Create a tar archive preserving devices and FIFOs, then compress with rar
tar --same-owner -cpf devices.tar /path/to/special/files
rar a devices.rar devices.tar

# Extraction
unrar x devices.rar
sudo tar -xpf devices.tar

Using this two-step process allows unrar to manage data compression while delegating the restoration of devices and pipes to a utility designed for system-level node recreation.