File tree Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import { History } from './history';
25
25
import * as containerUtils from './container-utils' ;
26
26
import { Messages } from '/@shared/src/messages/Messages' ;
27
27
import { telemetryLogger } from './extension' ;
28
- import { checkPrereqs , isLinux } from './machine-utils' ;
28
+ import { checkPrereqs , isLinux , getUidGid } from './machine-utils' ;
29
29
30
30
export class BootcApiImpl implements BootcApi {
31
31
private history : History ;
@@ -244,6 +244,10 @@ export class BootcApiImpl implements BootcApi {
244
244
return isLinux ( ) ;
245
245
}
246
246
247
+ async getUidGid ( ) : Promise < string > {
248
+ return getUidGid ( ) ;
249
+ }
250
+
247
251
// The API does not allow callbacks through the RPC, so instead
248
252
// we send "notify" messages to the frontend to trigger a refresh
249
253
// this method is internal and meant to be used by the API implementation
Original file line number Diff line number Diff line change @@ -138,3 +138,12 @@ const linux = os.platform() === 'linux';
138
138
export function isLinux ( ) : boolean {
139
139
return linux ;
140
140
}
141
+
142
+ // Get the GID and UID of the current user and return in the format gid:uid
143
+ // in order for this to work, we must get this information from process.exec
144
+ // since there is no native way via node
145
+ export async function getUidGid ( ) : Promise < string > {
146
+ const { stdout : uidOutput } = await extensionApi . process . exec ( 'id' , [ '-u' ] ) ;
147
+ const { stdout : gidOutput } = await extensionApi . process . exec ( 'id' , [ '-g' ] ) ;
148
+ return `${ uidOutput . trim ( ) } :${ gidOutput . trim ( ) } ` ;
149
+ }
Original file line number Diff line number Diff line change @@ -125,6 +125,17 @@ async function fillArchitectures(historyInfo: BootcBuildInfo[]) {
125
125
}
126
126
}
127
127
128
+ // This will fill the chown function by getting the user and group ID from the OS
129
+ // and filling in the information in the chown input field.
130
+ async function fillChownOption() {
131
+ try {
132
+ const gidUid = await bootcClient .getUidGid ();
133
+ buildChown = gidUid ;
134
+ } catch (error ) {
135
+ console .error (' Error getting UID and GID:' , error );
136
+ }
137
+ }
138
+
128
139
async function validate() {
129
140
let prereqs = await bootcClient .checkPrereqs ();
130
141
if (prereqs ) {
@@ -293,6 +304,10 @@ onMount(async () => {
293
304
await fillBuildOptions (historyInfo );
294
305
await fillArchitectures (historyInfo );
295
306
307
+ if (isLinux ) {
308
+ await fillChownOption ();
309
+ }
310
+
296
311
validate ();
297
312
});
298
313
@@ -701,12 +716,13 @@ export function goToHomePage(): void {
701
716
name =" chown"
702
717
id =" chown"
703
718
bind:value ={buildChown }
704
- placeholder =" GID and UID parameters (ex. 1000:1000)"
719
+ placeholder =" UID and GID parameters (ex. 1000:1000)"
705
720
class =" w-full"
706
721
aria-label =" chown-select" />
707
722
</div >
708
723
<p class =" text-sm text-[var(--pd-content-text)] pt-2" >
709
- This option allows you to change the owner and group of the files in the output directory.
724
+ Linux only. By default the UID and GID of the current user is used. This option allows you to
725
+ change the owner and group of the files in the output directory.
710
726
</p >
711
727
</div >
712
728
{/if }
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export abstract class BootcApi {
36
36
abstract generateUniqueBuildID ( name : string ) : Promise < string > ;
37
37
abstract openLink ( link : string ) : Promise < void > ;
38
38
abstract isLinux ( ) : Promise < boolean > ;
39
+ abstract getUidGid ( ) : Promise < string > ;
39
40
abstract telemetryLogUsage ( eventName : string , data ?: Record < string , unknown > | undefined ) : Promise < void > ;
40
41
abstract telemetryLogError ( eventName : string , data ?: Record < string , unknown > | undefined ) : Promise < void > ;
41
42
}
You can’t perform that action at this time.
0 commit comments