#! /bin/sh

if [ "$1" = "--version" ]
then
cat << EOF
tomoyo-savepolicy 2.3.0

Copyright (C) 2005-2010 NTT DATA CORPORATION.

This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
EOF
elif [ "$1" = "--help" ]
then
cat << EOF
Usage: tomoyo-savepolicy [e][d][a][f][p][m][u] [{-|policy_dir} [remote_ip:remote_port]]

This program saves TOMOYO Linux's policy from kernel into files.

 e     Save exception policy. ( /sys/kernel/security/tomoyo/exception_policy => policy_dir/exception_policy.conf )

 d     Save domain policy. ( /sys/kernel/security/tomoyo/domain_policy => policy_dir/domain_policy.conf )

 a     Save exception policy and domain policy. This is default.

 p     Save profile. ( /sys/kernel/security/tomoyo/profile => policy_dir/profile.conf )

 m     Save manager. ( /sys/kernel/security/tomoyo/manager => policy_dir/manager.conf )

 u     Print meminfo. Implies '-' option. ( /sys/kernel/security/tomoyo/meminfo )

 f     Forcefully save even if the on-memory policy and the on-disk policy are identical.

 -     Write policy to stdout. Specify only one of "edpmu" option when you use this option.

 policy_dir     Save policy files into policy_dir directory. Must starts with / .
                Default is none if remote_ip:remote_port is specified, /etc/tomoyo/ otherwise.

 remote_ip:remote_port     Receive policy from agent listening at specified IP address and port number. 

Examples:

# tomoyo-savepolicy
 Save exception policy and domain policy.

# tomoyo-savepolicy e
 Save exception policy.

# tomoyo-savepolicy /etc/tomoyo/192.168.1.1/ 192.168.1.1:10000
 Receive policy from 192.168.1.1:10000 and save into /etc/tomoyo/192.168.1.1/ directory.

EOF
else
cat << EOF | help2man -i - -N -s 8 -n "Save TOMOYO Linux's policy" $0 | gzip -9 > man8/tomoyo-savepolicy.8.gz
[SEE ALSO]

 tomoyo-loadpolicy (8)
 tomoyo-editpolicy-agent (8)

[AUTHORS]

 penguin-kernel _at_ I-love.SAKURA.ne.jp

EOF
fi
exit 0
