Skip to content

Commit

Permalink
Merge pull request #22882 from bjornfor/wireshark
Browse files Browse the repository at this point in the history
nixos: add programs.wireshark option
  • Loading branch information
globin committed Feb 20, 2017
2 parents ec2c9d5 + 7ec5faa commit 12b4556
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
./programs/tmux.nix
./programs/venus.nix
./programs/vim.nix
./programs/wireshark.nix
./programs/wvdial.nix
./programs/xfs_quota.nix
./programs/xonsh.nix
Expand Down
42 changes: 42 additions & 0 deletions nixos/modules/programs/wireshark.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ 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
setcap 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 ];
users.extraGroups.wireshark = {};

security.wrappers.dumpcap = {
source = "${wireshark}/bin/dumpcap";
capabilities = "cap_net_raw+p";
owner = "root";
group = "wireshark";
permissions = "u+rx,g+x";
};
};
}
3 changes: 2 additions & 1 deletion nixos/modules/security/wrappers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let
, source
, owner ? "nobody"
, group ? "nogroup"
, permissions ? "u+rx,g+x,o+x"
, ...
}:
assert (lib.versionAtLeast (lib.getVersion config.boot.kernelPackages.kernel) "4.3");
Expand All @@ -45,7 +46,7 @@ let
${pkgs.libcap.out}/bin/setcap "cap_setpcap,${capabilities}" $wrapperDir/${program}
# Set the executable bit
chmod u+rx,g+x,o+x $wrapperDir/${program}
chmod ${permissions} $wrapperDir/${program}
'';

###### Activation script for the setuid wrappers
Expand Down

0 comments on commit 12b4556

Please sign in to comment.