ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: Alexey Gladkov <legion@altlinux.ru>
To: sisyphus@lists.altlinux.org
Subject: Re: [sisyphus] Вопрос по os-release
Date: Thu, 28 Feb 2013 15:59:26 +0400
Message-ID: <512F469E.9070102@altlinux.ru> (raw)
In-Reply-To: <512F4102.1000505@etersoft.ru>

28.02.2013 15:35, Pavel Vainerman wrote:
>> У паранои должны быть пределы иначе можно перестать доверять выводу
>> системных утилит и содержимому конфигов.
>     согласен.. при условии (того, что вы написали ниже).

Я продемонстрирую почему я так толсто троллингово возмущаюсь:

$ dd if=/dev/urandom of=/tmp/badfile count=1 bs=512

$ cat /tmp/test.sh
#!/bin/sh -efu

. /tmp/badfile || echo "BAD FILE"
echo "END"

$ /tmp/test.sh
/tmp/badfile: line 1: unexpected EOF while looking for matching ``'

$ echo "Foo bar baz" > /tmp/badfile

$ LANG=C /tmp/test.sh
/tmp/badfile: line 1: Foo: command not found


Шеллы могут быть любыми, но результат будет один: синтаксическая ошибка.

Таким образом нарушается базовое условие формата этого конфига и
обработать такой сорс можно только через subshell:

$ cat /tmp/test.sh
#!/bin/sh -efu

( . /tmp/badfile ) || echo "BAD FILE"
echo "END"

$ /tmp/test.sh
/tmp/zzz: line 1: Foo: command not found
BAD FILE
END

Но в этом случае переменные из этого конфига не забрать простым
способом и это всё равно, что выуживать их sed'ом по одной. Как раз
этого хотели избежать создатели формата этого файла.

А учитывая, что формат допускает вот такие конструкции:

Example: NAME=Fedora or NAME="Debian GNU/Linux".

получение значений sed'ом делается ещё более весёлой задачей.

> если из этого сообщения будет понятно что битый файл os-release
> (ну или что где то в нём ошибка)..

Как я показал выше показать что именно файл битый можно, но выглядеть
эта проверка будет очень забавно. Безусловно я добавлю её раз возник
прецедент с записью туда мусора.

-- 
Rgrds, legion



  reply	other threads:[~2013-02-28 11:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-28  5:30 Sergei Epiphanov
2013-02-28  7:11 ` Alexey Gladkov
2013-02-28  8:12   ` Vladimir Lettiev
2013-02-28 10:26     ` Андрей Черепанов
2013-02-28 10:06   ` Sergei Epiphanov
2013-02-28 10:25     ` Alexey Gladkov
2013-02-28 10:29       ` Michael Shigorin
2013-02-28 11:15         ` Alexey Gladkov
2013-02-28 11:19           ` Pavel Vainerman
2013-02-28 11:30             ` Alexey Gladkov
2013-02-28 11:35               ` Pavel Vainerman
2013-02-28 11:59                 ` Alexey Gladkov [this message]
2013-02-28 12:03                   ` Pavel Vainerman
2013-02-28 12:26                     ` Alexey Gladkov
2013-02-28 12:57                       ` Pavel Vainerman
2013-03-01 16:50                       ` Dmitry V. Levin
2013-02-28 12:16                   ` Michael Shigorin
2013-02-28 11:52               ` Aleksey Novodvorsky
2013-02-28 13:35               ` Sergei Epiphanov
2013-02-28 13:34       ` Sergei Epiphanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512F469E.9070102@altlinux.ru \
    --to=legion@altlinux.ru \
    --cc=sisyphus@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git