Skip to content

Commit

Permalink
Merge pull request #5 from NCAR/Hua-work-dsarch
Browse files Browse the repository at this point in the history
add dsarch.c to rda_python_dsarch
  • Loading branch information
zaihuaji authored Jan 31, 2025
2 parents 6da2cb0 + 50de7cf commit f361233
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rda_python_dsarch"
version = "1.0.2"
version = "1.0.3"
authors = [
{ name="Zaihua Ji", email="[email protected]" },
]
Expand All @@ -28,7 +28,7 @@ include-package-data = true
where = ["src"]

[tool.setuptools.package-data]
"rda_pyhton_dsarch" = ["dsarch.usg"]
"rda_pyhton_dsarch" = ["dsarch.usg", "dsarch.c"]

[project.urls]
"Homepage" = "https://github.com/NCAR/rda-python-dsarch"
Expand Down
48 changes: 48 additions & 0 deletions src/rda_python_dsarch/dsarch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/***************************************************************************************\
*
* Title: dsarch.c
* Author: Zaihua Ji, [email protected]
* Date: 2024-01-30
* Purpose: C wrapper to setuid for dsarch python scripts
*
* Instruction:
*
* dsarch.c $LOCHOME/bin/dsarch.c
* cd $LOCHOME/bin/
* gcc -o dsarch dsarch.c
* chmod 4750 dsarch
*
* $LOCHOME: /usr/local/decs On DECS machines, and /ncar/rda/setuid on DAV
* $ENVHOME: /glade/u/home/rdadata/rdamsenv on DECS machines, and
* /glade/work/zji/conda-envs/pg-rda on DAV
*
\***************************************************************************************/

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* main program */
int main(int argc, char *argv[]) {
char *name;
char prog[128];
char pext[] = ".py";

strcpy(prog, getenv("ENVHOME"));
strcat(prog, "/bin/");
name = strrchr(argv[0], '/');
if(name == (char *)NULL) {
strcat(prog, argv[0]);
} else {
strcat(prog, ++name);
}
name = strrchr(prog, '.');
if(name == (char *)NULL || strcmp(name, pext) != 0) {
strcat(prog, pext);
}

/* call Python script */
execv(prog, argv);
}

0 comments on commit f361233

Please sign in to comment.