2008年10月28日火曜日

Samba 3.2.4のACL設定を解析

source/smbd/posix_acl.cより

create_canon_ace_lists()でACLを設定

ここで、NT4形式のACLをPOSIX形式のACLにマッピングしている様子。

if (nt4_compatible_acls()) {
/*
* The security mask may be UNIX_ACCESS_NONE which should map into
* no permissions (we overload the WRITE_OWNER bit for this) or it
* should be one of the ALL/EXECUTE/READ/WRITE bits. Arrange for this
* to be so. Any other bits override the UNIX_ACCESS_NONE bit.
*/

/*
* Convert GENERIC bits to specific bits.
*/

se_map_generic(&psa->access_mask, &file_generic_mapping);

psa->access_mask &= (UNIX_ACCESS_NONE|FILE_ALL_ACCESS);

if(psa->access_mask != UNIX_ACCESS_NONE)
psa->access_mask &= ~UNIX_ACCESS_NONE;
}

se_map_generic()は後で調査してみよう。

次のこの部分では、Windowsの継承ACLを、PosixのDefault ACLに変換。

/*
* Deal with the fact that NT 4.x re-writes the canonical format
* that we return for default ACLs. If a directory ACE is identical
* to a inherited directory ACE then NT changes the bits so that the
* first ACE is set to OI|IO and the second ACE for this SID is set
* to CI. We need to repair this. JRA.
*/

for(i = 0; i < dacl->num_aces; i++) {
SEC_ACE *psa1 = &dacl->aces[i];

for (j = i + 1; j < dacl->num_aces; j++) {
SEC_ACE *psa2 = &dacl->aces[j];

if (psa1->access_mask != psa2->access_mask)
continue;

if (!sid_equal(&psa1->trustee, &psa2->trustee))
continue;

/*
* Ok - permission bits and SIDs are equal.
* Check if flags were re-written.
*/

if (psa1->flags & SEC_ACE_FLAG_INHERIT_ONLY) {

psa1->flags |= (psa2->flags & (SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT));
psa2->flags &= ~(SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT);

} else if (psa2->flags & SEC_ACE_FLAG_INHERIT_ONLY) {

psa2->flags |= (psa1->flags & (SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT));
psa1->flags &= ~(SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT);

}
}
}


最後に個々のACLを、Posix ACLに変換

1. Everyoneは、Posixのotherに変換。

if( sid_equal(¤t_ace->trustee, &global_sid_World)) {
current_ace->owner_type = WORLD_ACE;
current_ace->unix_ug.world = -1;
current_ace->type = SMB_ACL_OTHER;


2. ファイル所有者は、Posixのownerに設定

} else if (sid_equal(¤t_ace->trustee, &global_sid_Creator_Owner)) {
current_ace->owner_type = UID_ACE;
current_ace->unix_ug.uid = pst->st_uid;
current_ace->type = SMB_ACL_USER_OBJ;


3. ファイル所有グループは、Posixのgroupに設定

} else if (sid_equal(¤t_ace->trustee, &global_sid_Creator_Group)) {
current_ace->owner_type = GID_ACE;
current_ace->unix_ug.gid = pst->st_gid;
current_ace->type = SMB_ACL_GROUP_OBJ;


4. ACLが操作中のユーザーと同じならownerに設定。それ以外なら、拡張ACLとして設定。

} else if (sid_to_uid( ¤t_ace->trustee, ¤t_ace->unix_ug.uid)) {
current_ace->owner_type = UID_ACE;
/* If it's the owning user, this is a user_obj, not
* a user. */
if (current_ace->unix_ug.uid == pst->st_uid) {
current_ace->type = SMB_ACL_USER_OBJ;
} else {
current_ace->type = SMB_ACL_USER;
}


5. ACLが操作中のユーザーのプライマリグループなら、Posixのgroupに設定。それ以外なら、拡張ACLとして設定。

} else if (sid_to_gid( ¤t_ace->trustee, ¤t_ace->unix_ug.gid)) {
current_ace->owner_type = GID_ACE;
/* If it's the primary group, this is a group_obj, not
* a group. */
if (current_ace->unix_ug.gid == pst->st_gid) {
current_ace->type = SMB_ACL_GROUP_OBJ;
} else {
current_ace->type = SMB_ACL_GROUP;
}

こんな感じかな。


Samba 3.2.4 + Solarisでmake test nss_modulesがエラー

ずいぶん前にパッチを登録していたのがcommitされた。忘れてた。

http://gitweb.samba.org/?p=samba.git;a=commit;h=1c6aa01e1f2f5e7ec1a55aace9392622d91b04c5


そんな組み合わせを実行する人はものすごく少ないと思われるけど。


samba 3.0.32でnet rpc oldjoinが失敗

いつの頃からか、net rpc oldjoinが失敗することが判明。
パッチを登録しておいた。


https://bugzilla.samba.org/show_bug.cgi?id=5855


2008年10月23日木曜日

Ubuntu 8.04のslapdのapparmorを無効に設定

$ sudo touch /etc/apparmor.d/disable/usr.sbin.slapd
$ sudo /etc/init.d/apparmor reload


Ubuntu 8.04のOpenLDAP

1000万件のデーターを投入しようとしたら、BDBのトランザクションログで
/パーティションが一杯になってしまったので、
dbconfig set_flags DB_LOG_AUTOREMOVE
を追加し、/var/lib/ldapから、空きのある別パーティションにBDBの保存場所を変更してみた。

ところが、
invalid path: Permission denied
ということで、slapdが起動しない。

調べてみたところ、Ubuntu 8.04からはデフォルトでAppArmorによって、/var/lib/ldap以外に
OpenLDAPのデーターを書き込むのが禁止されているらしい。

http://www.openldap.org/lists/openldap-software/200808/msg00203.html



2008年10月22日水曜日

Google Apps Email Settings API

Google Appsでユーザー作成時に、POPやIMAPを一括で有効にするための
Email Settings APIが利用可能になった。

http://code.google.com/apis/apps/email_settings/developers_guide_protocol.html

ライブラリも対応済み。


サーバー移転

このブログを運用していたサーバーを移転したので、テストの投稿。


2008年10月2日木曜日

Ubuntu 8.04 + emobile H11HWでBluetoothモデム接続

H11HWの「設定」-「接続設定」-「Bluetoothオン/オフ」で「オン」に。
同じく、「設定」-「接続設定」-「モデム」で「Bluetooth」に。

$ hcitool scan
Scanning ...
00:1E:10:11:33:D4 H11HW

$ sdptool browse 00:1E:10:11:33:D4

ここで、H11HW側に「承諾」の画面が表示されるので、PINコードを入力。

H11HW側にPINコードを入力すると、Ubuntu側にPINコードの入力要求が表示されるので、
PINコードを入力。

ターミナルに次のような表示が行われるので、「Dialup Networking」のエントリのチャンネルを確認。
$ sdptool browse 00:1E:10:11:33:D4
Browsing 00:1E:10:11:33:D4 ...
Service Name: Voice Gateway
Service RecHandle: 0x10000
Service Class ID List:
"Headset Audio Gateway" (0x1112)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

Service Name: Voice Gateway
Service RecHandle: 0x10001
Service Class ID List:
"Handfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105

Service Name: A2DP Source
Service RecHandle: 0x10002
Service Class ID List:
"Audio Source" (0x110a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 25
"AVDTP" (0x0019)
uint16: 0x100
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Advanced Audio" (0x110d)
Version: 0x0100

Service Name: AVRCP Target
Service RecHandle: 0x10003
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x100
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0100

Service Name: Serial Port
Service RecHandle: 0x10004
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 16
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0100

Service Name: Information Synchronization
Service RecHandle: 0x10005
Service Class ID List:
"IrMC Sync" (0x1104)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 17
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"IrMC Sync" (0x1104)
Version: 0x0100

Service Name: Object Push
Service RecHandle: 0x10006
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 18
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100

Service Name: File Transfer
Service RecHandle: 0x10007
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 19
"OBEX" (0x0008)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"OBEX File Transfer" (0x1106)
Version: 0x0100

Service Name: Dial-up Networking
Service RecHandle: 0x10008
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 8
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

以上の結果をもとに、/etc/bluetooth/rfcomm.confに以下を設定
rfcomm0 {
bind yes;
device 00:1E:10:11:33:D4;
channel 8;
comment "H11HW Bluetooth device";
}

Bluetoothサービスを再起動して、設定内容を反映。
$ sudo /etc/init.d/bluetooth restart

/dev/rfcomm0が作成されていることを確認する。

あとはpppconfigでemobileの設定を行えば、利用可能。