[release] v0.17.0-unstable10

This commit is contained in:
Yann Stepienik
2024-10-07 21:10:25 +01:00
parent c523a53b3c
commit b0c181cd8d
2 changed files with 19 additions and 19 deletions

View File

@@ -5,11 +5,14 @@ import TerminalComponent from "../../../../components/terminal";
import * as API from '../../../../api';
import { useTranslation } from "react-i18next";
import { useClientInfos } from "../../../../utils/hooks";
const TerminalHeader = () => {
const [open, setOpen] = React.useState(false);
const [status, setStatus] = React.useState(false);
const { t, Trans } = useTranslation();
const {role} = useClientInfos();
const isAdmin = role === "2";
useEffect(() => {
API.getStatus().then((res) => {
@@ -21,8 +24,7 @@ const TerminalHeader = () => {
setOpen((prevOpen) => !prevOpen);
};
return (
<>
return isAdmin ? (<>
<IconButton
disableRipple
color="secondary"
@@ -61,8 +63,7 @@ const TerminalHeader = () => {
}}>Close</Button>
</DialogActions>
</Dialog>
</>
);
</>) : null
}
export default TerminalHeader;

View File

@@ -1,14 +1,11 @@
package main
import (
// "context"
"net/http"
"os/exec"
// "syscall"
"syscall"
"time"
"io"
// "os"
// "os/signal"
"github.com/creack/pty"
"github.com/gorilla/websocket"
@@ -56,6 +53,19 @@ func HostTerminalRoute(w http.ResponseWriter, r *http.Request) {
// Create arbitrary command.
c := exec.Command("bash")
// Specify the UID
uid := uint32(1000) // Replace with the desired UID
gid := uint32(1000) // Replace with the primary GID of the user
c.SysProcAttr = &syscall.SysProcAttr{
Credential: &syscall.Credential{
Uid: uid,
Gid: gid,
},
}
// Set environment variables for better terminal emulation
// env := os.Environ()
env := []string{}
@@ -101,17 +111,6 @@ func HostTerminalRoute(w http.ResponseWriter, r *http.Request) {
// go func() { _, _ = io.Copy(ptmx, os.Stdin) }()
// _, _ = io.Copy(os.Stdout, ptmx)
// Specify the UID you want to run the command as
// uid := uint32(1000) // Replace with the desired UID
// gid := uint32(1000) // Replace with the primary GID of the user
// Set the user and group ID of the process
// cmd.SysProcAttr = &syscall.SysProcAttr{
// Credential: &syscall.Credential{
// Uid: uid,
// Gid: gid,
// },
// }
// stdin, err := cmd.StdinPipe()
// if err != nil {