psb_status: init at 0-unstable-2024-10-10

Changed files
+64 -6
pkgs
by-name
io
ps
psb_status
+20 -6
pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch
···
diff --git a/commands.c b/commands.c
-
index a83f1d5..b3f217a 100644
+
index a28e6da..0f76ac7 100644
--- a/commands.c
+++ b/commands.c
-
@@ -152,1 +152,7 @@ build_symlink_name(const char *path_to_bin, const struct cmd_info *cmd)
+
@@ -20,6 +20,7 @@
+
#include <stdlib.h>
+
#include <string.h>
+
#include <unistd.h>
+
+#include <limits.h>
+
#include <errno.h>
+
#include "commands.h"
+
#include "platform.h"
+
@@ -150,7 +151,13 @@ build_symlink_name(const char *path_to_bin, const struct cmd_info *cmd)
+
{
+
static char link_name[FILENAME_MAX];
+
- snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name);
-
+ int result = snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name);
+
+ int result = snprintf(link_name, PATH_MAX, "%s/%s", path_to_bin, cmd->name);
+
-
+ if (result >= FILENAME_MAX) {
-
+ link_name[FILENAME_MAX - 1] = '\0';
-
+ } else if (result < 0) {
+
+ if (result >= PATH_MAX) {
+
+ link_name[PATH_MAX - 1] = '\0';
+
+ } else if (result < 0) {
+ link_name[0] = '\0';
+ }
+
+
return link_name;
+
}
+44
pkgs/by-name/ps/psb_status/package.nix
···
+
{
+
lib,
+
stdenvNoCC,
+
fetchFromGitHub,
+
bash,
+
iotools,
+
makeWrapper,
+
}:
+
+
stdenvNoCC.mkDerivation (finalAttrs: {
+
pname = "psb_status";
+
version = "0-unstable-2024-10-10";
+
+
src = fetchFromGitHub {
+
owner = "mkopec";
+
repo = "psb_status";
+
rev = "be896832c53d6b0b70cf8a87f7ee46ad33deefc2";
+
hash = "sha256-4anPyjO8y3FgnYWa4bGFxI8Glk9srw/XF552tnixc8I=";
+
};
+
+
dontBuild = true;
+
+
nativeBuildInputs = [ makeWrapper ];
+
+
installPhase = ''
+
runHook preInstall
+
+
mkdir -p $out/bin
+
install -m755 psb_status.sh $out/bin/psb_status
+
wrapProgram $out/bin/psb_status \
+
--prefix PATH : ${lib.makeBinPath [ iotools ]}
+
+
runHook postInstall
+
'';
+
+
meta = {
+
description = "Script to check Platform Secure Boot enablement on Zen based AMD CPUs";
+
homepage = "https://github.com/mkopec/psb_status";
+
license = lib.licenses.mit;
+
maintainers = with lib.maintainers; [ phodina ];
+
platforms = [ "x86_64-linux" ];
+
mainProgram = "psb_status";
+
};
+
})