| ナビゲーションリンクをスキップ | |
| 印刷ビューの終了 | |
|
Trusted Extensions 開発者ガイド Oracle Solaris 10 1/13 Information Library (日本語) |
1. Trusted Extensions API およびセキュリティーポリシー
9. Solaris Trusted Extensions ラベル API のための試験的な Java バインディング
ファイルの機密ラベルを取得し、そのラベルに対して操作を実行できます。
このコード例では、getlabel() ルーチンを使用してファイルのラベルを取得します。fgetlabel() ルーチンも同様に使用できますが、それはファイル記述子に作用します。
#include <tsol/label.h>
main()
{
m_label_t* docLabel;
const char* path = "/zone/restricted/documents/designdoc.odt";
int retval;
char* label_string;
/* allocate label and get the file label specified by path */
docLabel = m_label_alloc(MAC_LABEL);
retval = getlabel(path, docLabel);
/* translate the file's label to a string and print the string */
retval = label_to_str(docLabel, &label_string, M_LABEL, LONG_NAMES);
printf("The file's label = %s\n", label_string);
/* free allocated memory */
m_label_free(docLabel);
free(label_string);
}
このプログラムを実行した場合、出力はこのように表示される可能性があります。
The file's label = CONFIDENTIAL : INTERNAL USE ONLY