nixos: add programs.wireshark option
To be able to use Wireshark as an ordinary user, the 'dumpcap' program
must be installed setuid root. This module module simplifies such a
configuration to simply:
programs.wireshark.enable = true;
The setuid wrapper is available for users in the 'wireshark' group.
Changes v1 -> v2:
- add "defaultText" to the programs.wireshark.package option (AFAIK,
that prevents the manual from being needlessly rebuilt when the
package changes)
This commit is contained in:
committed by
Robin Gloster
parent
070825d443
commit
8f3e6fdd8c
57
nixos/modules/programs/wireshark.nix
Normal file
57
nixos/modules/programs/wireshark.nix
Normal file
@@ -0,0 +1,57 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.wireshark;
|
||||
wireshark = cfg.package;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options = {
|
||||
|
||||
programs.wireshark = {
|
||||
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to add Wireshark to the global environment and configure a
|
||||
setuid wrapper for 'dumpcap' for users in the 'wireshark' group.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.wireshark-cli;
|
||||
defaultText = "pkgs.wireshark-cli";
|
||||
description = ''
|
||||
Which Wireshark package to install in the global environment.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ wireshark ];
|
||||
|
||||
security.wrappers.dumpcap = {
|
||||
source = "${wireshark}/bin/dumpcap";
|
||||
owner = "root";
|
||||
group = "wireshark";
|
||||
setuid = true;
|
||||
setgid = false;
|
||||
permissions = "u+rx,g+x";
|
||||
};
|
||||
|
||||
users.extraGroups.wireshark.gid = config.ids.gids.wireshark;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user