Skip to content

Commit

Permalink
logging: Update the mac address retrieval
Browse files Browse the repository at this point in the history
With this patch will be calling hwinfo utility to retrieve
Permanent HW Address / MAC Address for wlp0s5f0 network interface.
As we cannot rely on the sys interface for mac retrieval possibly
due to MAC randomization.

Signed-off-by: Vunny Sodhi <[email protected]>
  • Loading branch information
vunnyso authored and brianmcgillion committed Jul 29, 2024
1 parent b1508e9 commit b404254
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/common/logging/hw-mac-retrieve.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}: let
# TODO: replace sshCommand and MacCommand with givc rpc to retrieve Mac Address
sshCommand = "${pkgs.sshpass}/bin/sshpass -p ghaf ${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no ghaf@net-vm";
macCommand = "cat /sys/class/net/wlp0s5f0/address";
macCommand = "${pkgs.hwinfo}/bin/hwinfo --network --only /class/net/wlp0s5f0 | ${pkgs.gawk}/bin/awk '/Permanent HW Address/ {print $4}'";
macAddressPath = config.ghaf.logging.identifierFilePath;
in {
options.ghaf.logging.identifierFilePath = lib.mkOption {
Expand Down Expand Up @@ -36,6 +36,8 @@ in {
ExecStart = ''
${pkgs.bash}/bin/bash -c "echo -n $(${sshCommand} ${macCommand}) > ${macAddressPath}"
'';
Restart = "on-failure";
RestartSec = "1";
};
};
};
Expand Down

0 comments on commit b404254

Please sign in to comment.