sudoersファイルのマルチパラメータワイルドカード一致?

sudoersファイルのマルチパラメータワイルドカード一致?

限定されたパラメータセット(いくつかのオプション)を受け入れるsudoerでアイテムを作成する方法を理解しようとしていますが、コマンドは依然として非常に制限的です。

これらの制限を制限する簡単な方法はありますか?

ユーザーは-wフラグとオプションの値を使用して実行できますが、それでも制限されていることを願っています。 -wオプションの値をハードコードしたくありません。ユーザーはこれらのコマンドのいずれかを実行できる必要があります。ここで、10 は任意の数値です。

/usr/bin/iptables -nvL *
/usr/bin/iptables -w -nvL *
/usr/bin/iptables -w 10 -nvL *

私はこの4つの項目を思い出しました。オプションの値を定義するより良い方法はありますか?

username ALL=(root) NOPASSWD: /usr/bin/iptables -nvL *
username ALL=(root) NOPASSWD: /usr/bin/iptables -w -nvL *
username ALL=(root) NOPASSWD: /usr/bin/iptables -w [[\:digit\:]] -nvL *
username ALL=(root) NOPASSWD: /usr/bin/iptables -w [[\:digit\:]][[\:digit\:]] -nvL *

ベストアンサー1

申し訳ありませんが、
「?」または、「*」などのワイルドカードを使用したくない場合は、必要なものを非常に正確に提供する必要があります。

sudoersのマニュアルページによると、ユニバーサルワイルドカードのみを提供しています。

Wildcards
  sudo allows shell-style wildcards (aka meta or glob characters) to be used in host names,
  path names and command line arguments in the sudoers file.  Wildcard matching is done via the
  glob(3) and fnmatch(3) functions as specified by IEEE Std 1003.1 (“POSIX.1”).

  *         Matches any set of zero or more characters (including white space).

  ?         Matches any single character (including white space).

  [...]     Matches any character in the specified range.

  [!...]    Matches any character not in the specified range.

  \x        For any character ‘x’, evaluates to ‘x’.  This is used to escape special characters
            such as: ‘*’, ‘?’, ‘[’, and ‘]’.

  NOTE THAT THESE ARE NOT REGULAR EXPRESSIONS.
  Unlike a regular expression there is no way to match one or more characters within a range.

おすすめ記事