generated from NCAR/rda-python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from NCAR/Hua-work-dsarch
add dsarch.c to rda_python_dsarch
- Loading branch information
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]" }, | ||
] | ||
|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |