решено: как указать рзмещение secrets.tdb для smbd

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС.

Модераторы: SLEDopit, Модераторы разделов

Аватара пользователя
McSim
Сообщения: 419
Статус: Экспериментатор
ОС: заGNU/Linux Debian

решено: как указать рзмещение secrets.tdb для smbd

Сообщение McSim »

Доброго времени, камрады.
Путаюсь настроить SAMBA на 2 разных интерфейса с разными smb.conf.
Самба из репы, собрана со следующими параметрами путями:

Код: Выделить всё

avr ~ # smbd -b | grep /
   Build host:  Linux biber 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 i686 GNU/Linux
   SRCDIR:      /build/buildd-samba_3.5.6~dfsg-3squeeze7-i386-oNRyFO/samba-3.5.6~dfsg/source3
   BUILDDIR:    /build/buildd-samba_3.5.6~dfsg-3squeeze7-i386-oNRyFO/samba-3.5.6~dfsg/source3
   SBINDIR: /usr/sbin
   BINDIR: /usr/bin
   SWATDIR: /usr/share/samba/swat
   CONFIGFILE: /etc/samba/smb.conf
   LOGFILEBASE: /var/log/samba
   LMHOSTSFILE: /etc/samba/lmhosts
   LIBDIR: /usr/lib/samba
   MODULESDIR: /usr/lib/samba
   LOCKDIR: /var/run/samba
   STATEDIR: /var/lib/samba
   CACHEDIR: /var/cache/samba
   PIDDIR: /var/run/samba
   SMB_PASSWD_FILE: /etc/samba/smbpasswd
   PRIVATE_DIR: /etc/samba

smb-avr.conf содержит вот такую инфу:

Код: Выделить всё

avr ~ # testparm -s /etc/samba/smb-avr.conf
Load smb config files from /etc/samba/smb-avr.conf.comment
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[backup$]"
Processing section "[windows$]"
Processing section "[video$]"
Processing section "[Мусорка продажников]"
Loaded services file OK.
WARNING: You have some share names that are longer than 12 characters.
These may not be accessible to some older clients.
(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)
Server role: ROLE_DOMAIN_MEMBER
[global]
        workgroup = DOMAIN
        realm = DOMAIN.LOCAL
        server string = cсервер
        interfaces = eth1
        bind interfaces only = Yes
        security = ADS
        auth methods = winbind
        password server = server.domain.local
        username map = /etc/samba/userssmb
        log level = 4
        log file = /var/log/samba-avr/log.%m
        smb ports = 139
        socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
        load printers = No
        disable spoolss = Yes
        show add printer wizard = No
        lock directory = /var/run/samba-avr
        state directory = /var/lib/samba-avr
        cache directory = /var/cache/samba-avr
        pid directory = /var/run/samba-avr
        usershare path =
        idmap uid = 10000-20000
        idmap gid = 10000-20000
        winbind separator = ^
        winbind cache time = 600
        winbind enum users = Yes
        winbind enum groups = Yes
        winbind use default domain = Yes
        winbind refresh tickets = Yes
        winbind offline logon = Yes
<...>

init-скрипт модифицировал:

Код: Выделить всё

avr ~ # cat /etc/init.d/samba-avr
#!/bin/sh

### BEGIN INIT INFO
# Provides:          samba-avr
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $network $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Should-Start:      slapd
# Should-Stop:       slapd
# Short-Description: start Samba AVR daemons (nmbd and smbd)
### END INIT INFO


# Defaults
RUN_MODE="daemons"

# Reads config file (will override defaults above)
[ -r /etc/default/samba-avr ] && . /etc/default/samba-avr

PIDDIR=/var/run/samba-avr
NMBDPID=$PIDDIR/nmbd.pid
SMBDPID=$PIDDIR/smbd.pid
CONF=/etc/samba/smb-avr.conf

# clear conflicting settings from the environment
unset TMPDIR

# See if the daemons are there
test -x /usr/sbin/nmbd -a -x /usr/sbin/smbd || exit 0

. /lib/lsb/init-functions

case "$1" in
        start)
                log_daemon_msg "Starting Samba daemons in DOMAIN DOMAIN.LOCAL and host AVR"
                # Make sure we have our PIDDIR, even if it's on a tmpfs
                install -o root -g root -m 755 -d $PIDDIR

                NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' $CONF 2>/dev/null`
                if [ "$NMBD_DISABLED" != 'Yes' ]; then
                        log_progress_msg "nmbd"
                        if ! start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/nmbd -- -D $NMBDOPTIONS -s $CONF
                        then
                                log_end_msg 1
                                exit 1
                        fi
                fi

                if [ "$RUN_MODE" != "inetd" ]; then
                        log_progress_msg "smbd"
                        if ! start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/smbd -- -D $SMBDOPTIONS -s $CONF ; then
                                log_end_msg 1
                                exit 1
                        fi
                fi

                log_end_msg 0
                ;;
        stop)
                log_daemon_msg "Stopping Samba daemons AVR"
                log_progress_msg "nmbd"

                start-stop-daemon --stop --quiet --pidfile $NMBDPID
                # Wait a little and remove stale PID file
                sleep 1
                if [ -f $NMBDPID ] && ! ps h `cat $NMBDPID` > /dev/null
                then
                        # Stale PID file (nmbd was succesfully stopped),
                        # remove it (should be removed by nmbd itself IMHO.)
                        rm -f $NMBDPID
                fi

                if [ "$RUN_MODE" != "inetd" ]; then
                        log_progress_msg "smbd"
                        start-stop-daemon --stop --quiet --pidfile $SMBDPID
                        # Wait a little and remove stale PID file
                        sleep 1
                        if [ -f $SMBDPID ] && ! ps h `cat $SMBDPID` > /dev/null
                        then
                                # Stale PID file (nmbd was succesfully stopped),
                                # remove it (should be removed by smbd itself IMHO.)
                                rm -f $SMBDPID
                        fi
                fi

                log_end_msg 0

                ;;
        reload)
                log_daemon_msg "Reloading /etc/samba/smb.conf" "smbd only on AVR"

                start-stop-daemon --stop --signal HUP --pidfile $SMBDPID

                log_end_msg 0
                ;;
        restart|force-reload)
                $0 stop
                sleep 1
                $0 start
                ;;
        status)
                status="0"
                NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' $CONF 2>/dev/null`
                if [ "$NMBD_DISABLED" != "Yes" ]; then
                        status_of_proc -p $NMBDPID /usr/sbin/nmbd nmbd || status=$?
                fi
                if [ "$RUN_MODE" != "inetd" ]; then
                        status_of_proc -p $SMBDPID /usr/sbin/smbd smbd || status=$?
                fi
                if [ "$NMBD_DISABLED" = "Yes" -a "$RUN_MODE" = "inetd" ]; then
                        status="4"
                fi
                exit $status
                ;;
        *)
                echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload|status}"
                exit 1
                ;;
esac

exit 0

При этом, при запуске service samba-avr start, smbd не запускается с сообщением:

Код: Выделить всё

[2012/05/05 13:56:29.663057,  2] lib/util_tdb.c:521(tdb_wrap_log)
  tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/secrets.tdb: Нет такого файла или каталога
[2012/05/05 13:56:29.663313,  3] lib/dbwrap_tdb.c:357(db_open_tdb)
  Could not open tdb: Нет такого файла или каталога
[2012/05/05 13:56:29.663496,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/secrets.tdb
[2012/05/05 13:56:29.664169,  3] smbd/server.c:1165(main)
  loaded services
[2012/05/05 13:56:29.664340,  3] smbd/server.c:1180(main)
  Becoming a daemon.
[2012/05/05 13:56:29.667499,  2] lib/util_tdb.c:521(tdb_wrap_log)
  tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/secrets.tdb: Нет такого файла или каталога
[2012/05/05 13:56:29.669931,  3] lib/dbwrap_tdb.c:357(db_open_tdb)
  Could not open tdb: Нет такого файла или каталога
[2012/05/05 13:56:29.670839,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/secrets.tdb
[2012/05/05 13:56:29.671751,  0] smbd/server.c:1223(main)
  ERROR: smbd can not open secrets.tdb

В итоге, я прихожу к выводу, что по какой-то причине smbd не принимает параметр state directory, который задает положение tdb файлов.
Отсюда вопрос - как ему указать этот параметр, чтобы брал не по умолчанию?
Спасибо сказали:
Аватара пользователя
bormant
Сообщения: 1354

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение bormant »

McSim писал(а):
05.05.2012 14:41
по какой-то причине smbd не принимает параметр state directory, который задает положение tdb файлов.

По документированной причине.
man smb.conf, поиск по secrets.tdb:
private dir (G)
This parameters defines the directory smbd will use for storing such files as smbpasswd and secrets.tdb.
Default: private dir = ${prefix}/private
Спасибо сказали:
Аватара пользователя
McSim
Сообщения: 419
Статус: Экспериментатор
ОС: заGNU/Linux Debian

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение McSim »

bormant писал(а):
05.05.2012 15:14
private dir (G)
This parameters defines the directory smbd will use for storing such files as smbpasswd and secrets.tdb.
Default: private dir = ${prefix}/private

Спасибо за ответ, bormant.
Я тоже об этом думал, но просмотрев на вывод:

Код: Выделить всё

avr ~ # testparm -sv /etc/samba/smb-avr.conf | grep priv
Load smb config files from /etc/samba/smb-avr.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[backup$]"
Processing section "[windows$]"
Processing section "[video$]"
Processing section "[Мусорка продажников]"
Loaded services file OK.
WARNING: You have some share names that are longer than 12 characters.
These may not be accessible to some older clients.
(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)
Server role: ROLE_DOMAIN_MEMBER
        private dir = /etc/samba
        enable privileges = Yes

меня /etc/samba сбила с толку.... Сейчас попробую...
Спасибо сказали:
Аватара пользователя
McSim
Сообщения: 419
Статус: Экспериментатор
ОС: заGNU/Linux Debian

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение McSim »

безрезультатно...

Код: Выделить всё

avr ~ # testparm -s /etc/samba/smb-avr.conf 2>/dev/null | grep priv
        private dir = /var/cache/samba-avr

лог:

Код: Выделить всё

[2012/05/05 15:46:43.753825,  2] lib/util_tdb.c:521(tdb_wrap_log)
  tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/secrets.tdb: Нет такого файла или каталога
[2012/05/05 15:46:43.754104,  3] lib/dbwrap_tdb.c:357(db_open_tdb)
  Could not open tdb: Нет такого файла или каталога
[2012/05/05 15:46:43.754296,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/secrets.tdb
[2012/05/05 15:46:43.754970,  3] smbd/server.c:1165(main)
  loaded services
[2012/05/05 15:46:43.755142,  3] smbd/server.c:1180(main)
  Becoming a daemon.
[2012/05/05 15:46:43.770245,  2] lib/util_tdb.c:521(tdb_wrap_log)
  tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/secrets.tdb: Нет такого файла или каталога
[2012/05/05 15:46:43.770790,  3] lib/dbwrap_tdb.c:357(db_open_tdb)
  Could not open tdb: Нет такого файла или каталога
[2012/05/05 15:46:43.771006,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/secrets.tdb
[2012/05/05 15:46:43.771824,  0] smbd/server.c:1223(main)
  ERROR: smbd can not open secrets.tdb
Спасибо сказали:
Аватара пользователя
bormant
Сообщения: 1354

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение bormant »

А если ручками запустить:

Код: Выделить всё

sudo smbd -D -s /etc/samba/smb-avr.conf

что будет в логе насчёт secrets.tdb?
Спасибо сказали:
Аватара пользователя
McSim
Сообщения: 419
Статус: Экспериментатор
ОС: заGNU/Linux Debian

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение McSim »

bormant писал(а):
06.05.2012 13:45
А если ручками запустить:

Код: Выделить всё

sudo smbd -D -s /etc/samba/smb-avr.conf

что будет в логе насчёт secrets.tdb?

аналогично:

Код: Выделить всё

[2012/05/06 23:30:02.291059,  2] lib/util_tdb.c:521(tdb_wrap_log)
  tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/secrets.tdb: Нет такого файла или каталога
[2012/05/06 23:30:02.291185,  3] lib/dbwrap_tdb.c:357(db_open_tdb)
  Could not open tdb: Нет такого файла или каталога
[2012/05/06 23:30:02.291249,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/secrets.tdb
[2012/05/06 23:30:02.291934,  3] smbd/server.c:1165(main)
  loaded services
[2012/05/06 23:30:02.292005,  3] smbd/server.c:1180(main)
  Becoming a daemon.
[2012/05/06 23:30:02.334016,  2] lib/util_tdb.c:521(tdb_wrap_log)
  tdb(unnamed): tdb_open_ex: could not open file /var/lib/samba/secrets.tdb: Нет такого файла или каталога
[2012/05/06 23:30:02.334307,  3] lib/dbwrap_tdb.c:357(db_open_tdb)
  Could not open tdb: Нет такого файла или каталога
[2012/05/06 23:30:02.334390,  0] passdb/secrets.c:73(secrets_init)
  Failed to open /var/lib/samba/secrets.tdb
[2012/05/06 23:30:02.334995,  0] smbd/server.c:1223(main)
  ERROR: smbd can not open secrets.tdb
Спасибо сказали:
Аватара пользователя
McSim
Сообщения: 419
Статус: Экспериментатор
ОС: заGNU/Linux Debian

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение McSim »

походу smbd использует единый файл /var/lib/samba/secrets.tdb и /var/lib/samba/passdb.tdb для всех конфигов...
посему вопрос закрывается...
Спасибо сказали:
Аватара пользователя
bormant
Сообщения: 1354

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение bormant »

Фо хум хау.

Slackware-13.37, samba-3.5.14

Смотрим первый конфиг и трассу запуска с ним (не имеющие отношения строки выкинул):

Код: Выделить всё

# testparm -sv | grep "private dir"
Load smb config files from /etc/samba/smb.conf
    private dir = /etc/samba/private

# strace -eopen smbd
open("/etc/samba/smb.conf", O_RDONLY|O_LARGEFILE) = 4
open("/etc/samba/private/secrets.tdb", O_RDWR|O_CREAT|O_LARGEFILE, 0600) = 4


Смотрим второй конфиг и трассу запуска с ним:

Код: Выделить всё

# testparm -sv smb1.conf|grep "private dir"
Load smb config files from smb1.conf
    private dir = /root/smb1

# strace -eopen smbd -s /root/smb1.conf
open("/root/smb1.conf", O_RDONLY|O_LARGEFILE) = 5
open("/root/smb1/secrets.tdb", O_RDWR|O_CREAT|O_LARGEFILE, 0600) = 4


Так что, или баг в ранней версии, или запатченая самба в вашем дистрибутиве.
Спасибо сказали:
Аватара пользователя
McSim
Сообщения: 419
Статус: Экспериментатор
ОС: заGNU/Linux Debian

Re: решено: как указать рзмещение secrets.tdb для smbd

Сообщение McSim »

bormant писал(а):
08.05.2012 22:31
Так что, или баг в ранней версии, или запатченая самба в вашем дистрибутиве.

возможно и баг. багрепорт не смог отработать, потому что в конфигах/логах имеется киррилица и падает с сообщением:

Код: Выделить всё

(72-114/114) Is the bug you found listed above [y|N|b|m|r|q|s|f|?]? n
Maintainer for samba is 'Debian Samba Maintainers <pkg-samba-maint@lists.alioth.debian.org>'.
Looking up dependencies of samba...
Getting changed configuration files...
Traceback (most recent call last):
  File "/usr/bin/reportbug", line 2098, in <module>
    main()
  File "/usr/bin/reportbug", line 1045, in main
    return iface.user_interface()
  File "/usr/bin/reportbug", line 1155, in user_interface
    main()
  File "/usr/bin/reportbug", line 1045, in main
    return iface.user_interface()
  File "/usr/bin/reportbug", line 1733, in user_interface
    conftext = conftext + u'%s %s\n' % (f, confinfo[f])
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 10: ordinal not in range(128)

При этом, secrets.tdb содержит данные для обоих конфигов...

Код: Выделить всё

avr ~ # tdbtool
tdb> open /var/lib/samba/secrets.tdb
tdb> info
8 records totalling 271 bytes
tdb> keys
key 39 bytes: SECRETS/SALTING_PRINCIPAL/DES/UIK.LOCAL
key 36 bytes: SECRETS/MACHINE_SEC_CHANNEL_TYPE/UIK
key 28 bytes: SECRETS/MACHINE_PASSWORD/UIK
key 36 bytes: SECRETS/MACHINE_LAST_CHANGE_TIME/UIK
key 33 bytes: SECRETS/MACHINE_PASSWORD.PREV/UIK
key 15 bytes: SECRETS/SID/AVR
key 17 bytes: SECRETS/SID/FILES
key 15 bytes: SECRETS/SID/UIK


P.S. Что-то форум сегодня лагает... :(
Спасибо сказали: