Skip to content

Commit 603aad9

Browse files
committed
Add support for geteuid in os module
1 parent 79289d4 commit 603aad9

File tree

7 files changed

+41
-0
lines changed

7 files changed

+41
-0
lines changed

graalpython/com.oracle.graal.python.cext/posix/posix.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,10 @@ int64_t call_getuid() {
549549
return getuid();
550550
}
551551

552+
int64_t call_geteuid() {
553+
return geteuid();
554+
}
555+
552556
int64_t call_getgid() {
553557
return getgid();
554558
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,15 @@ long getUid(@CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib) {
559559
}
560560
}
561561

562+
@Builtin(name = "geteuid", minNumOfPositionalArgs = 0)
563+
@GenerateNodeFactory
564+
public abstract static class GetEUidNode extends PythonBuiltinNode {
565+
@Specialization
566+
long getUid(@CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib) {
567+
return posixLib.geteuid(getPosixSupport());
568+
}
569+
}
570+
562571
@Builtin(name = "getgid", minNumOfPositionalArgs = 0)
563572
@GenerateNodeFactory
564573
public abstract static class GetGidNode extends PythonBuiltinNode {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,13 @@ public long getuid() {
19471947
return 1000;
19481948
}
19491949

1950+
@ExportMessage
1951+
@SuppressWarnings("static-method")
1952+
@TruffleBoundary
1953+
public long geteuid() {
1954+
throw new UnsupportedPosixFeatureException("Emulated geteuid not supported");
1955+
}
1956+
19501957
@ExportMessage
19511958
@SuppressWarnings("static-method")
19521959
@TruffleBoundary

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ImageBuildtimePosixSupport.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,12 @@ final long getuid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary
629629
return nativeLib.getuid(nativePosixSupport);
630630
}
631631

632+
@ExportMessage
633+
final long geteuid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) {
634+
checkNotInImageBuildtime();
635+
return nativeLib.geteuid(nativePosixSupport);
636+
}
637+
632638
@ExportMessage
633639
final long getgid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) {
634640
checkNotInImageBuildtime();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/LoggingPosixSupport.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,13 @@ final long getuid(
805805
return logExit("getuid", "%d", lib.getuid(delegate));
806806
}
807807

808+
@ExportMessage
809+
final long geteuid(
810+
@CachedLibrary("this.delegate") PosixSupportLibrary lib) {
811+
logEnter("geteuid", "");
812+
return logExit("geteuid", "%d", lib.geteuid(delegate));
813+
}
814+
808815
@ExportMessage
809816
final long getgid(
810817
@CachedLibrary("this.delegate") PosixSupportLibrary lib) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ private enum PosixNativeFunction {
206206
call_wtermsig("(sint32):sint32"),
207207
call_wstopsig("(sint32):sint32"),
208208
call_getuid("():sint64"),
209+
call_geteuid("():sint64"),
209210
call_getgid("():sint64"),
210211
call_getppid("():sint64"),
211212
call_getpgid("(sint64):sint64"),
@@ -1104,6 +1105,11 @@ public long getuid(@Shared("invoke") @Cached InvokeNativeFunction invokeNode) {
11041105
return invokeNode.callLong(this, PosixNativeFunction.call_getuid);
11051106
}
11061107

1108+
@ExportMessage
1109+
public long geteuid(@Shared("invoke") @Cached InvokeNativeFunction invokeNode) {
1110+
return invokeNode.callLong(this, PosixNativeFunction.call_geteuid);
1111+
}
1112+
11071113
@ExportMessage
11081114
public long getgid(@Shared("invoke") @Cached InvokeNativeFunction invokeNode) {
11091115
return invokeNode.callLong(this, PosixNativeFunction.call_getgid);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PosixSupportLibrary.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ public abstract class PosixSupportLibrary extends Library {
272272

273273
public abstract long getuid(Object receiver);
274274

275+
public abstract long geteuid(Object receiver);
276+
275277
public abstract long getgid(Object receiver);
276278

277279
public abstract long getppid(Object receiver);

0 commit comments

Comments
 (0)