ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] [JT] glibc: обработка пустых подстрок в PATH, LD_PRELOAD etc
@ 2008-03-27 10:26 Konstantin S. Uvarin
  2008-03-27 10:38 ` Slava Semushin
  2008-03-29  1:03 ` [devel] " Dmitry V. Levin
  0 siblings, 2 replies; 3+ messages in thread
From: Konstantin S. Uvarin @ 2008-03-27 10:26 UTC (permalink / raw)
  To: ALT Devel discussion list

Приветствую. 

  Давно не дает мне покоя один вопрос: для чего glibc интерпретирует пустую 
подстроку в $PATH, $LD_PRELOAD и т.п. как текущий каталог? Ведь если 
пользователю нужно именно текущий каталог указать, он и укажет PATH=$PATH:.

  А так получается, что команда PATH=$PATH:$SOMEVAR делает не то, что 
задумывалось, если SOMEVAR неопределена. 

  Причем я смотрел код, это специально выделено в отдельный случай и написан 
комментарий даже. Зачем, зачем это сделано? Не понимаю...

In elf/dl-load.c, function fillin_rpath:

      /* `strsep' can pass an empty string.  This has to be 
         interpreted as `use the current directory'. */
      if (len == 0)
        {
          static const char curwd[] = "./";
          cp = (char *) curwd;
        }

-- 
Konstantin S. Uvarin
Главный редактор, крякнув, осушил стопку. Новости радостно закрякали в ответ.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [devel] [JT] glibc: обработка пустых подстрок в PATH, LD_PRELOAD etc
  2008-03-27 10:26 [devel] [JT] glibc: обработка пустых подстрок в PATH, LD_PRELOAD etc Konstantin S. Uvarin
@ 2008-03-27 10:38 ` Slava Semushin
  2008-03-29  1:03 ` [devel] " Dmitry V. Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Slava Semushin @ 2008-03-27 10:38 UTC (permalink / raw)
  To: ALT Linux Team development discussions

27.03.08, Konstantin S. Uvarin<khedin / mail.ru> написал(а):
[...]
>   А так получается, что команда PATH=$PATH:$SOMEVAR делает не то, что
>  задумывалось, если SOMEVAR неопределена.

Да-да, один из мэйнтейнеров Debian, помнится, уже указывал на эту
"фичу". Навешал стопку багов в багзиллу Дебиана. В lifearea, такой баг
даже попал в CVE...


-- 
+ Slava Semushin | slava.semushin @ gmail.com
+ ALT Linux Team | php-coder @ altlinux.ru

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [devel] glibc: обработка пустых подстрок в PATH, LD_PRELOAD etc
  2008-03-27 10:26 [devel] [JT] glibc: обработка пустых подстрок в PATH, LD_PRELOAD etc Konstantin S. Uvarin
  2008-03-27 10:38 ` Slava Semushin
@ 2008-03-29  1:03 ` Dmitry V. Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry V. Levin @ 2008-03-29  1:03 UTC (permalink / raw)
  To: ALT Devel discussion list

[-- Attachment #1: Type: text/plain, Size: 1834 bytes --]

On Thu, Mar 27, 2008 at 01:26:42PM +0300, Konstantin S. Uvarin wrote:
>   Давно не дает мне покоя один вопрос: для чего glibc интерпретирует пустую 
> подстроку в $PATH, $LD_PRELOAD и т.п. как текущий каталог? Ведь если 
> пользователю нужно именно текущий каталог указать, он и укажет PATH=$PATH:.

Это требование стандарта (legacy feature).
Привожу цитату из SUSv3 про $PATH полностью (жаль, что вы её не нашли раньше):

"This variable shall represent the sequence of path prefixes that certain
functions and utilities apply in searching for an executable file known
only by a filename.  The prefixes shall be separated by a colon ( ':' ).
When a non-zero-length prefix is applied to this filename, a slash shall
be inserted between the prefix and the filename.  A zero-length prefix is
a legacy feature that indicates the current working directory.	It appears
as two adjacent colons ( "::" ), as an initial colon preceding the rest
of the list, or as a trailing colon following the rest of the list.
A strictly conforming application shall use an actual pathname (such
as .) to represent the current working directory in PATH .  The list
shall be searched from beginning to end, applying the filename to each
prefix, until an executable file with the specified name and appropriate
execution permissions is found.  If the pathname being sought contains
a slash, the search through the path prefixes shall not be performed.
If the pathname begins with a slash, the specified path is resolved
(see Pathname Resolution).  If PATH is unset or is set to null, the path
search is implementation-defined."

>   А так получается, что команда PATH=$PATH:$SOMEVAR делает не то, что 
> задумывалось, если SOMEVAR неопределена. 

Тогда пишите правильно, например,
PATH="$PATH${SOMEVAR:+:$SOMEVAR}"


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-29  1:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-27 10:26 [devel] [JT] glibc: обработка пустых подстрок в PATH, LD_PRELOAD etc Konstantin S. Uvarin
2008-03-27 10:38 ` Slava Semushin
2008-03-29  1:03 ` [devel] " Dmitry V. Levin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/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 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

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


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