[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

slashes in filenames [was Re: Error while trying to install openssh-server on Buster]



On 2020-07-23 at 06:26, Andrei POPESCU wrote:

> On Mi, 22 iul 20, 16:26:24, Jonathan Dowland wrote:
> 
>> On Wed, Jul 22, 2020 at 07:38:54AM -0400, Greg Wooledge wrote:
>> 
>>> Apparently this unit refers to the root file system.  I have no
>>> idea why it's masked for you, but that's where I'd start
>>> looking.
>> 
>> Yes. Unfortunately Systemd decided to forbid '/' in unit names,
> 
> Seriously? Could you please show me how would I create a file on *nix
> containing '/' in the name?

It's theoretically possible, but AFAIK basically nothing would support
it or work properly with it.

The only ways I can think of to do it that I wouldn't expect to be
prohibited by the intermediary layers involved (such as the C standard
library) would be A: direct file I/O not involving a library (which I'd
guess would probably need to be written in architecture-specific ASM),
and B: opening the device underlying the filesystem in a hex editor or
similar and modifying the stored data in the inode.

The latter is relatively straightforward to do with a tiny filesystem
which is backed not by a physical device but by a file created for the
purpose, and in fact I've just done it:

$ dd if=/dev/zero of=/tmp/testfs bs=1K count=100
$ /sbin/mke2fs /tmp/testfs
[as root:] mount -o loop /tmp/testfs /mnt/loop/
[as root:] touch /mnt/loop/filename-without-slashes
[as root:] umount /mnt/loop/
$ vbindiff /tmp/testfs
 f
 t
 slash
 [left arrow]
 e
 [right arrow]
 f
 [Enter]
 [Esc]
 y
 q
[as root:] mount -o loop /tmp/testfs /mnt/loop/
$ ls /mnt/loop/

(Commands paraphrased slightly, but the effect should be identical,
barring typos on my part. I've made no effort to identify any checksums,
hashes, or other validity data that may exist, never mind update them.)

The result, unsurprisingly enough, is:

ls: reading directory '/mnt/loop/': Input/output error

because neither ls nor basically anything in the stack it sits on
supports this, at least not with an ext2 filesystem.


In principle it would be possible to design the underlying parts of the
system to apply escaping to slashes in filenames, and require escaping
to be applied in order to reference files with such. But apparently this
has never been done, and I have a vague impression that it might be
prohibited by some relevant spec (and, probably, RFC) or another.


All of that said: the only reason I can see for any of this to be
relevant to systemd's prohibiting / in unit names is if systemd is
designed so that there must be a file whose name matches that of the
unit, without variations. There are reasons to make that design
decision, but it's not an inherent requirement, so this can from a
certain perspective be seen as the result of a design decision on the
part of the systemd project.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: