File tree Expand file tree Collapse file tree 3 files changed +24
-11
lines changed
com.oracle.graal.python.cext/src
com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
Original file line number Diff line number Diff line change @@ -331,9 +331,14 @@ int getPid() {
331
331
332
332
@ Builtin (name = "getuid" , minNumOfPositionalArgs = 0 )
333
333
@ GenerateNodeFactory
334
- public abstract static class GetUidNode extends PythonBuiltinNode {
334
+ public abstract static class GetUidNode extends PythonUnaryBuiltinNode {
335
335
@ Specialization
336
336
int getPid () {
337
+ return getSystemUid ();
338
+ }
339
+
340
+ @ TruffleBoundary
341
+ int getSystemUid () {
337
342
String osName = System .getProperty ("os.name" );
338
343
if (osName .contains ("Linux" )) {
339
344
return (int ) new com .sun .security .auth .module .UnixSystem ().getUid ();
Original file line number Diff line number Diff line change 48
48
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
49
49
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
50
50
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
51
+ import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
51
52
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
52
53
import com .oracle .truffle .api .dsl .NodeFactory ;
53
54
import com .oracle .truffle .api .dsl .Specialization ;
@@ -69,6 +70,11 @@ public abstract static class GetpwuidNode extends PythonUnaryBuiltinNode {
69
70
70
71
@ Specialization
71
72
Object doGetpwuid (int uid ) {
73
+ return factory ().createTuple (createPwuidObject (uid ));
74
+ }
75
+
76
+ @ TruffleBoundary
77
+ public Object [] createPwuidObject (int uid ) {
72
78
String osName = System .getProperty ("os.name" );
73
79
String username = System .getProperty ("user.name" );
74
80
String password = "NOT_AVAILABLE" ;
@@ -83,15 +89,17 @@ Object doGetpwuid(int uid) {
83
89
gid = unix .getGid ();
84
90
shell = "/bin/sh" ;
85
91
}
86
- return factory ().createTuple (new Object []{
87
- username ,
88
- password ,
89
- uid ,
90
- gid ,
91
- gecos ,
92
- homeDir ,
93
- shell
94
- });
92
+
93
+ return new Object []{
94
+ username ,
95
+ password ,
96
+ uid ,
97
+ gid ,
98
+ gecos ,
99
+ homeDir ,
100
+ shell
101
+ };
95
102
}
96
103
}
104
+
97
105
}
You can’t perform that action at this time.
0 commit comments