1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[AIX] ユーザ定義パスワードポリシー(pwdchecksの使用例)

Posted at

AIXのデフォルトの方式の他に、ユーザ定義のパスワードポリシーを設定することが出来ます。

参考資料:

chuser コマンド
https://www.ibm.com/docs/ja/aix/7.3?topic=c-chuser-command
New AIX Password Restrictions introduced in AIX 6.1 and 7.1
https://www.ibm.com/support/pages/new-aix-password-restrictions-introduced-aix-61-and-71
pwdrestrict_method サブルーチン
https://www.ibm.com/docs/ja/aix/7.3?topic=p-pwdrestrict-method-subroutine
-e オプション
https://www.ibm.com/docs/ja/openxl-c-and-cpp-aix/17.1.0?topic=co-e

手順:

1. チェックロジックを作成

渡される引数の種類と型は固定。
Messageには、任意の出力メッセージを指定可能。

サンプル:

入力が"PASSWORD"であればture、それ以外はfalse

# cat checktest.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int checktest_sub(
    char *UserName,
    char *NewPassword,
    char *OldPassword,
    char **Message
){
    *Message = (char *)malloc (100*sizeof(char));
    if(strncmp("PASSWORD", NewPassword, strlen("PASSWORD")) == 0 ){
        strcpy(*Message, "test success message\n");
        return(0);
    }else{
        strcpy(*Message, "test fail message\n");
        return(1);
    }
}
注意点:

・function名には"main"以外の名前を使用
・Message変数は必ずmalloc()で領域を確保

2. エントリーポイントを指定してコンパイル
  1. のチェックロジックで作成したfunction名(今回はchecktest_sub)をエントリーポイントとして指定
# ibm-clang -e checktest_sub checktest.c -o checktest
3. ユーザ属性に設定

pwdchecks属性に2.で作成したオブジェクトファイルを指定

# chuser pwdchecks=/work/checktest testuser

実行例:

# su - testuser
$ passwd
"testuser" のパスワード変更中
testuser の旧パスワード:
testuser の新パスワード: <== "PASSWORD"以外を入力
test fail message
testuser の新パスワード: <== "PASSWORD"を入力
test success message
もう一度、新パスワードを入力してください:
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?