Патчи к утилите pw.c версий FreeBSD 3.5-Stable, 4.0 по 4.3:

Проверьте свою систему:

[unix1]~ > pw lock help
Segmentation fault (core dumped)
[unix1]~ > 

после патчевания:

[unix1]~ > pw lock help
usage pw: lock [switches]
        -V etcdir      alternate /etc locations
        -C config      configuration file
        -q             quiet operation
[unix1]~ > 

Примечание: можно иметь альтернативную систему авторизации, например для
Squid и задавать путь к файлам и базам pwd:

pw -V /path/my_auth ...

Ручной вариант: - отредактировать файл /usr/src/usr.sbin/pw/pw.c в районе:


static void
cmdhelp(int mode, int which)
{
        if (which == -1)
                fprintf(stderr, "usage:\n  pw [user|group|lock|unlock] [add|del|
mod|show|next] [help|switches/values]\n");
        else if (mode == -1)
                fprintf(stderr, "usage:\n  pw %s [add|del|mod|show|next] [help|s
witches/values]\n", Which[which]);
        else {

                /*
                 * We need to give mode specific help
                 */
                static const char *help[W_NUM][M_NUM] =
                {
                        {
                                "usage: pw useradd [name] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n"
                                "  Adding users:\n"
                                "\t-n name        login name\n"
                                "\t-u uid         user id\n"
                                "\t-c comment     user name/comment\n"
                                "\t-d directory   home directory\n"
                                "\t-e date        account expiry date\n"
                                "\t-p date        password expiry date\n"
                                "\t-g grp         initial group\n"
                                "\t-G grp1,grp2   additional groups\n"
                                "\t-m [ -k dir ]  create and set up home\n"
                                "\t-s shell       name of login shell\n"
                                "\t-o             duplicate uid ok\n"
                                "\t-L class       user class\n"
                                "\t-h fd          read password on fd\n"
                                "\t-Y             update NIS maps\n"
                                "\t-N             no update\n"
                                "  Setting defaults:\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-D             set user defaults\n"
                                "\t-b dir         default home root dir\n"
                                "\t-e period      default expiry period\n"
                                "\t-p period      default password change period\n"
                                "\t-g group       default group\n"
                                "\t-G grp1,grp2   additional groups\n"
                                "\t-L class       default user class\n"
                                "\t-k dir         default home skeleton\n"
                                "\t-u min,max     set min,max uids\n"
                                "\t-i min,max     set min,max gids\n"
                                "\t-w method      set default password method\n"
                                "\t-s shell       default shell\n"
                                "\t-y path        set NIS passwd file path\n",
                                "usage: pw userdel [uid|name] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-n name        login name\n"
                                "\t-u uid         user id\n"
                                "\t-Y             update NIS maps\n"
                                "\t-r             remove home & contents\n",
                                "usage: pw usermod [uid|name] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n"
                                "\t-F             force add if no user\n"
                                "\t-n name        login name\n"
                                "\t-u uid         user id\n"
                                "\t-c comment     user name/comment\n"
                                "\t-d directory   home directory\n"
                                "\t-e date        account expiry date\n"
                                "\t-p date        password expiry date\n"
                                "\t-g grp         initial group\n"
                                "\t-G grp1,grp2   additional groups\n"
                                "\t-l name        new login name\n"
                                "\t-L class       user class\n"
                                "\t-m [ -k dir ]  create and set up home\n"
                                "\t-s shell       name of login shell\n"
                                "\t-w method      set new password using method\n"
                                "\t-h fd          read password on fd\n"
                                "\t-Y             update NIS maps\n"
                                "\t-N             no update\n",
                                "usage: pw usershow [uid|name] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-n name        login name\n"
                                "\t-u uid         user id\n"
                                "\t-F             force print\n"
                                "\t-P             prettier format\n"
                                "\t-a             print all users\n"
                                "\t-7             print in v7 format\n",
                                "usage: pw usernext [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n",
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- после
это строки добавить строки(за исключением квотирования):
------------------------------- quote -----------------------------------------
                                "usage pw: lock [switches]\n"
                                "\t-V etcdir      alternate /etc locations\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n",
                                "usage pw: unlock [switches]\n"
                                "\t-V etcdir      alternate /etc locations\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n"
------------------------------- end of quote ----------------------------------
                        },
                        {
                                "usage: pw groupadd [group|gid] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n"
                                "\t-n group       group name\n"
                                "\t-g gid         group id\n"
                                "\t-M usr1,usr2   add users as group members\n"
                                "\t-o             duplicate gid ok\n"
                                "\t-Y             update NIS maps\n"
                                "\t-N             no update\n",
                                "usage: pw groupdel [group|gid] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-n name        group name\n"
                                "\t-g gid         group id\n"
                                "\t-Y             update NIS maps\n",
                                "usage: pw groupmod [group|gid] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-C config      configuration file\n"
                                "\t-q             quiet operation\n"
                                "\t-F             force add if not exists\n"
                                "\t-n name        group name\n"
                                "\t-g gid         group id\n"
                                "\t-M usr1,usr2   replaces users as group members\n"
                                "\t-m usr1,usr2   add users as group members\n"
                                "\t-l name        new group name\n"
                                "\t-Y             update NIS maps\n"
                                "\t-N             no update\n",
                                "usage: pw groupshow [group|gid] [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-n name        group name\n"
                                "\t-g gid         group id\n"
                                "\t-F             force print\n"
                                "\t-P             prettier format\n"
                                "\t-a             print all accounting groups\n",
                                "usage: pw groupnext [switches]\n"
                                "\t-V etcdir      alternate /etc location\n"
                                "\t-C config      configuration file\n"
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- после
этой строки добавить (за исключением строк квотирования):
------------------------------ quote ---------------------------------------
                                "\t-q             quiet operation\n"
--------------------------- end of quote -----------------------------------
                        }
                };

                fprintf(stderr, help[which][mode]);
        }
        exit(EXIT_FAILURE);
}

Патчи для:

cd /usr/src/usr.sbin/pw/ wget -t 0 -c http://unix1.jinr.ru/~lavr/patch_pw (или pw_patch_3.5) patch < patchfile cp /usr/sbin/pw /usr/sbin/pw.orig make && make install

Прим.: возможны незначительные расхождения в sources, будьте осторожны.