ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] Q: squid - сил моих больше нет
@ 2004-12-22 14:13 Alexey I. Froloff
  2004-12-22 16:33 ` Alexey I. Froloff
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey I. Froloff @ 2004-12-22 14:13 UTC (permalink / raw)
  To: ALT Devel discussion list

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

Исходные данные: squid-2.5.STABLE7-alt{1,4}, ADS домен,
авторизация через самбовый ntlm_auth.  Надо внести сквида в
группу winbind и тогда наступит счастие...  А нифига.

# id squid
uid=23(squid) gid=23(squid) groups=23(squid),35(winbind)

Конфиг:

cache_effective_user squid
cache_effective_group squid

(cache_effective_group пробовал убирать - не помогает)

Смотрим ему в код (извините за размер):

src/main.c:475
static void
mainInitialize(void)
{
    /* chroot if configured to run inside chroot */
    if (Config.chroot_dir && chroot(Config.chroot_dir)) {
	fatal("failed to chroot");
    }
    if (opt_catch_signals) {
	squid_signal(SIGSEGV, death, SA_NODEFER | SA_RESETHAND);
	squid_signal(SIGBUS, death, SA_NODEFER | SA_RESETHAND);
    }
    squid_signal(SIGPIPE, SIG_IGN, SA_RESTART);
    squid_signal(SIGCHLD, sig_child, SA_NODEFER | SA_RESTART);

    setEffectiveUser();
    assert(Config.Sockaddr.http);
    if (httpPortNumOverride != 1)
	Config.Sockaddr.http->s.sin_port = htons(httpPortNumOverride);
    if (icpPortNumOverride != 1)
	Config.Port.icp = (u_short) icpPortNumOverride;

    _db_init(Config.Log.log, Config.debugOptions);
    fd_open(fileno(debug_log), FD_LOG, Config.Log.log);

src/main.c:437
static void
setEffectiveUser(void)
{
    leave_suid();               /* Run as non privilegied user */
#ifdef _SQUID_OS2_
    return;
#endif
    if (geteuid() == 0) {
        debug(0, 0) ("Squid is not safe to run as root!  If you must\n");
        debug(0, 0) ("start Squid as root, then you must configure\n");
        debug(0, 0) ("it to run as a non-priveledged user with the\n");
        debug(0, 0) ("'cache_effective_user' option in the config file.\n");
        fatal("Don't run Squid as root, set 'cache_effective_user'!");
    }
}       

src/tools.c:515
void
leave_suid(void)
{
    debug(21, 3) ("leave_suid: PID %d called\n", (int) getpid());
    if (Config.effectiveGroup) {
#if HAVE_SETGROUPS
        setgroups(1, &Config2.effectiveGroupID);
#endif
        if (setgid(Config2.effectiveGroupID) < 0)
            debug(50, 0) ("ALERT: setgid: %s\n", xstrerror());
    }
    if (geteuid() != 0) 
        return;
    /* Started as a root, check suid option */
    if (Config.effectiveUser == NULL)
        return;
    debug(21, 3) ("leave_suid: PID %d giving up root, becoming '%s'\n",
        (int) getpid(), Config.effectiveUser);
    if (!Config.effectiveGroup) {
        if (setgid(Config2.effectiveGroupID) < 0)
            debug(50, 0) ("ALERT: setgid: %s\n", xstrerror());
        if (initgroups(Config.effectiveUser, Config2.effectiveGroupID) < 0) {
            debug(50, 0) ("ALERT: initgroups: unable to set groups for User %s "
                "and Group %u", Config.effectiveUser,
                (unsigned) Config2.effectiveGroupID);
        }
    }       
#if HAVE_SETRESUID
    if (setresuid(Config2.effectiveUserID, Config2.effectiveUserID, 0) < 0)
        debug(50, 0) ("ALERT: setresuid: %s\n", xstrerror());
#elif HAVE_SETEUID
    if (seteuid(Config2.effectiveUserID) < 0)
        debug(50, 0) ("ALERT: seteuid: %s\n", xstrerror());
#else
    if (setuid(Config2.effectiveUserID) < 0)
        debug(50, 0) ("ALERT: setuid: %s\n", xstrerror());
#endif  
}   


Теперь смотрим в strace, сооветствующий этому коду:

32724 open("/proc/sys/kernel/ngroups_max", O_RDONLY) = -1 ENOENT (No such file or directory)
32724 setgroups32(1, [23])              = 0
32724 setgid32(23)                      = 0
32724 geteuid32()                       = 0
32724 setresuid32(23, 23, 0)            = 0
32724 geteuid32()                       = 23
32724 open("/var/log/squid/cache.log", O_RDWR|O_APPEND|O_CREAT, 0666) = 3

(В логах тишина, потому как он ещё не открыт к этому времени)

Первый geteuid32 из leave_suid(), второй из setEffectiveUser().
Config2.effectiveGroupID и Config2.effectiveUserID определены,
Config.effectiveUser тоже очевидно не NULL, потому как
setresuid() вызывается.  Где может быть проблема?  Я уже даже не
знаю куда ему смотреть...

-- 
Regards, Sir Raorn.
-------------------
>Где можно взять этот драйвер?  Я посмотрю, что там можно допилить для
>его сборки.
Перевожу:
"не фиг чайникам собирать модули ядра в пакеты".
		-- rider in devel@

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

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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-22 14:13 [devel] Q: squid - сил моих больше нет Alexey I. Froloff
@ 2004-12-22 16:33 ` Alexey I. Froloff
  2004-12-22 17:15   ` Dimitry V. Ketov
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey I. Froloff @ 2004-12-22 16:33 UTC (permalink / raw)
  To: ALT Devel discussion list

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

* Alexey I. Froloff <raorn@> [041222 17:14]:
> Исходные данные: squid-2.5.STABLE7-alt{1,4}, ADS домен,
> авторизация через самбовый ntlm_auth.  Надо внести сквида в
> группу winbind и тогда наступит счастие...  А нифига.

>     debug(21, 3) ("leave_suid: PID %d giving up root, becoming '%s'\n",
>         (int) getpid(), Config.effectiveUser);
>     if (!Config.effectiveGroup) {

Блин... :-/  Убил целый день на такую бнопню...

Почему _!_Config.effectiveGroup, когда Config.effectiveGroup
_всегда_ будет не NULL?!

кг/ам :-/

-- 
Regards, Sir Raorn.
-------------------
Никогда не меняйте uid вручную, пользуйтесь usermod(8).
		-- ldv in community@

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

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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-22 16:33 ` Alexey I. Froloff
@ 2004-12-22 17:15   ` Dimitry V. Ketov
  2004-12-22 18:11     ` Alexey I. Froloff
  0 siblings, 1 reply; 8+ messages in thread
From: Dimitry V. Ketov @ 2004-12-22 17:15 UTC (permalink / raw)
  To: ALT Devel discussion list

http://www.squid-cache.org/bugs/show_bug.cgi?id=1021
https://bugzilla.altlinux.org/show_bug.cgi?id=4182
http://www.squid-cache.org/Versions/v2/2.5/bugs/#squid-2.5.STABLE6-initgroups
...
synopsis  	cache_effective_user should gain the supplementary group memberships of the 
specified user. This is required to be able to configure sane permissions of several 
authentication backends such as pam_auth or winbind. In addition cache_effective_group 
should not be ignored when not starting Squid as root. If cache_effective_group is 
specified Squid should run as this and only this group.
...

Последнее предложение...

Д.

Alexey I. Froloff wrote:
> * Alexey I. Froloff <raorn@> [041222 17:14]:
> 
>>Исходные данные: squid-2.5.STABLE7-alt{1,4}, ADS домен,
>>авторизация через самбовый ntlm_auth.  Надо внести сквида в
>>группу winbind и тогда наступит счастие...  А нифига.
> 
> 
>>    debug(21, 3) ("leave_suid: PID %d giving up root, becoming '%s'\n",
>>        (int) getpid(), Config.effectiveUser);
>>    if (!Config.effectiveGroup) {
> 
> 
> Блин... :-/  Убил целый день на такую бнопню...
> 
> Почему _!_Config.effectiveGroup, когда Config.effectiveGroup
> _всегда_ будет не NULL?!
> 
> кг/ам :-/
> 


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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-22 17:15   ` Dimitry V. Ketov
@ 2004-12-22 18:11     ` Alexey I. Froloff
  2004-12-22 19:31       ` Dimitry V. Ketov
  2004-12-23  8:31       ` Denis Ovsienko
  0 siblings, 2 replies; 8+ messages in thread
From: Alexey I. Froloff @ 2004-12-22 18:11 UTC (permalink / raw)
  To: ALT Devel discussion list

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

* Dimitry V. Ketov <Dimitry.Ketov@> [041222 20:16]:
> starting Squid as root. If cache_effective_group is specified Squid should 
> run as this and only this group.
> ...

> Последнее предложение...
Угу.  Уже допёр сам, повесил #5767, локально запатчил и
протестировал.

Аднака blocker.  И в updates надоть.  (есть alt1.M24.2 AKA alt4
из сизифа).

-- 
Regards,
Sir Raorn.

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

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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-22 18:11     ` Alexey I. Froloff
@ 2004-12-22 19:31       ` Dimitry V. Ketov
  2004-12-23  6:42         ` Alexey I. Froloff
  2004-12-23  8:31       ` Denis Ovsienko
  1 sibling, 1 reply; 8+ messages in thread
From: Dimitry V. Ketov @ 2004-12-22 19:31 UTC (permalink / raw)
  To: ALT Devel discussion list



Alexey I. Froloff wrote:
>>starting Squid as root. If cache_effective_group is specified Squid should 
>>run as this and only this group.
>>...
> Угу.  Уже допёр сам, повесил #5767, локально запатчил и
> протестировал.
> 
> Аднака blocker.  И в updates надоть.  (есть alt1.M24.2 AKA alt4
> из сизифа).
Неее, это фича бай дизайн...
Не нашел в своей переписке с Henrik Nordstrom подтверждения этому, но помнится мне что все 
так и было...

Д.


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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-22 19:31       ` Dimitry V. Ketov
@ 2004-12-23  6:42         ` Alexey I. Froloff
  2004-12-23  6:55           ` Dimitry V. Ketov
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey I. Froloff @ 2004-12-23  6:42 UTC (permalink / raw)
  To: ALT Devel discussion list

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

* Dimitry V. Ketov <Dimitry.Ketov@> [041222 22:28]:
> >Аднака blocker.  И в updates надоть.  (есть alt1.M24.2 AKA alt4
> >из сизифа).
> Неее, это фича бай дизайн...
> Не нашел в своей переписке с Henrik Nordstrom подтверждения этому, но 
> помнится мне что все так и было...
Фича - в апстриме, а у нас это просто не работает.  Надо оторвать
установку дефолтного значения cache_effective_group.  В апстриме
нет дефолта, у нас - squid.

-- 
Regards, Sir Raorn.
-------------------
У биллинга ещё должна быть возможность срубить с линии клиента (если у
него на счету 1 цент, а он пытается себе весь интернет выкачать).
		-- mithraen in sisyphus@

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

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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-23  6:42         ` Alexey I. Froloff
@ 2004-12-23  6:55           ` Dimitry V. Ketov
  0 siblings, 0 replies; 8+ messages in thread
From: Dimitry V. Ketov @ 2004-12-23  6:55 UTC (permalink / raw)
  To: ALT Devel discussion list

Угу, понял.

Alexey I. Froloff wrote:
>>>Аднака blocker.  И в updates надоть.  (есть alt1.M24.2 AKA alt4
>>Неее, это фича бай дизайн...
> 
> Фича - в апстриме, а у нас это просто не работает.  Надо оторвать
> установку дефолтного значения cache_effective_group.  В апстриме
> нет дефолта, у нас - squid.


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

* Re: [devel] Q: squid - сил моих больше нет
  2004-12-22 18:11     ` Alexey I. Froloff
  2004-12-22 19:31       ` Dimitry V. Ketov
@ 2004-12-23  8:31       ` Denis Ovsienko
  1 sibling, 0 replies; 8+ messages in thread
From: Denis Ovsienko @ 2004-12-23  8:31 UTC (permalink / raw)
  To: ALT Devel discussion list


> Угу.  Уже допёр сам, повесил #5767, локально запатчил и
> протестировал.
Я отредактировал #5767, давайте дальше там.

-- 
    DO4-UANIC


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

end of thread, other threads:[~2004-12-23  8:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-22 14:13 [devel] Q: squid - сил моих больше нет Alexey I. Froloff
2004-12-22 16:33 ` Alexey I. Froloff
2004-12-22 17:15   ` Dimitry V. Ketov
2004-12-22 18:11     ` Alexey I. Froloff
2004-12-22 19:31       ` Dimitry V. Ketov
2004-12-23  6:42         ` Alexey I. Froloff
2004-12-23  6:55           ` Dimitry V. Ketov
2004-12-23  8:31       ` Denis Ovsienko

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