[GH-ISSUE #2970] Help for web app #2114

Closed
opened 2026-02-27 03:00:57 +03:00 by kerem · 13 comments
Owner

Originally created by @JimTR on GitHub (Jul 19, 2020).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/2970

User Story

As a web developer, I want to add gnu screen so that the web app works.

Basic info

  • Distro: [Ubuntu 18.04]
  • Game: [All]
  • Command: [status/start/stop/restart/console]
  • LinuxGSM version: [v20.1.3]

Further Information

I have a web interface for lgsm under development, however tmux does not 'play nice' with the web user even if this user is the same user as the lgsm user, but screen does. I have tried various methods to get tmux to work however when this achieved the are security issuses.
so the next method to try was to add screen functionality to lgsm which I have done. Currently my code will allow the user to choose either tmux or screen as the multiplexer by adding a variable to the config files(s).
my knowledge of bash can be written on a postage stamp so is there anyone out there that wishes to review my code additions & tell me where the couple of bugs are so they can be fixed rather than doing requests into the project

Further Reading

none yet
Provide any useful documentation or resources that might help.

Originally created by @JimTR on GitHub (Jul 19, 2020). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/2970 ## User Story As a web developer, I want to add gnu screen so that the web app works. ## Basic info * **Distro:** [Ubuntu 18.04] * **Game:** [All] * **Command:** [status/start/stop/restart/console] * **LinuxGSM version:** [v20.1.3] ## Further Information I have a web interface for lgsm under development, however tmux does not 'play nice' with the web user even if this user is the same user as the lgsm user, but screen does. I have tried various methods to get tmux to work however when this achieved the are security issuses. so the next method to try was to add screen functionality to lgsm which I have done. Currently my code will allow the user to choose either tmux or screen as the multiplexer by adding a variable to the config files(s). my knowledge of bash can be written on a postage stamp so is there anyone out there that wishes to review my code additions & tell me where the couple of bugs are so they can be fixed rather than doing requests into the project ## Further Reading none yet Provide any useful documentation or resources that might help.
kerem closed this issue 2026-02-27 03:00:57 +03:00
Author
Owner

@issue-label-bot[bot] commented on GitHub (Jul 19, 2020):

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

<!-- gh-comment-id:660627729 --> @issue-label-bot[bot] commented on GitHub (Jul 19, 2020): Issue Label Bot is not confident enough to auto-label this issue. See [dashboard](https://mlbot.net/data/GameServerManagers/LinuxGSM) for more details.
Author
Owner

@dgibbs64 commented on GitHub (Jul 19, 2020):

@Grimston any thoughts on this as I know you are creating something as well.

<!-- gh-comment-id:660627974 --> @dgibbs64 commented on GitHub (Jul 19, 2020): @Grimston any thoughts on this as I know you are creating something as well.
Author
Owner

@Grimston commented on GitHub (Jul 19, 2020):

I have it working in my own project using tmux, as I have just implemented a full SSH web terminal.
I don't really see a need to move to screen, or even provide an option, as it should be trivial to just attach to the session or as I used to use, call: tmux capture-pane to get the current output on a timer.

Another option I looked at was to use the log file and stream that if changes are made.

<!-- gh-comment-id:660632016 --> @Grimston commented on GitHub (Jul 19, 2020): I have it working in my own project using tmux, as I have just implemented a full SSH web terminal. I don't really see a need to move to screen, or even provide an option, as it should be trivial to just attach to the session or as I used to use, call: `tmux capture-pane` to get the current output on a timer. Another option I looked at was to use the log file and stream that if changes are made.
Author
Owner

@JimTR commented on GitHub (Jul 19, 2020):

@Grimston try running up apache using the suexec module to ensure you have the correct user then run php code like <?php if (php_sapi_name() == "cli") { // In cli-mode define ('cr',PHP_EOL); } else { // Not in cli-mode define ('cr','<br>'); } echo 'Running as user '.shell_exec('whoami').cr; echo 'passthru '.cr; $output = passthru('tmux ls'); echo 'tmux output'.cr; echo trim($output); $output= passthru('screen -ls'); echo 'Screen Output'.cr; echo trim($output); echo PHP_EOL.'shell_exec'.cr; $output = shell_exec('tmux ls'); echo 'Tmux Output'.cr; echo trim($output); $output = shell_exec('screen -ls'); echo 'screen Output'.cr; echo trim($output); ?>
from the the command line and via a browser you will see the difference .. if you can find the fix for this let me know

<!-- gh-comment-id:660637556 --> @JimTR commented on GitHub (Jul 19, 2020): @Grimston try running up apache using the suexec module to ensure you have the correct user then run php code like `<?php if (php_sapi_name() == "cli") { // In cli-mode define ('cr',PHP_EOL); } else { // Not in cli-mode define ('cr','<br>'); } echo 'Running as user '.shell_exec('whoami').cr; echo 'passthru '.cr; $output = passthru('tmux ls'); echo 'tmux output'.cr; echo trim($output); $output= passthru('screen -ls'); echo 'Screen Output'.cr; echo trim($output); echo PHP_EOL.'shell_exec'.cr; $output = shell_exec('tmux ls'); echo 'Tmux Output'.cr; echo trim($output); $output = shell_exec('screen -ls'); echo 'screen Output'.cr; echo trim($output); ?> ` from the the command line and via a browser you will see the difference .. if you can find the fix for this let me know
Author
Owner

@thegreatstorm commented on GitHub (Jul 19, 2020):

@JimTR If you want a webapp to interact with LinuxGSM I recommend using Python Flask. So you can just call the backend with rest api.
This is the app I been working on.
https://github.com/thegreatstorm/projectstorm

GitHub
ProjectStorm! Contribute to thegreatstorm/projectstorm development by creating an account on GitHub.
<!-- gh-comment-id:660679225 --> @thegreatstorm commented on GitHub (Jul 19, 2020): @JimTR If you want a webapp to interact with LinuxGSM I recommend using Python Flask. So you can just call the backend with rest api. This is the app I been working on. https://github.com/thegreatstorm/projectstorm <blockquote><img src="https://avatars1.githubusercontent.com/u/29154863?s=400&v=4" width="48" align="right"><div><img src="https://github.githubassets.com/favicons/favicon.svg" height="14"> GitHub</div><div><strong><a href="https://github.com/thegreatstorm/projectstorm">thegreatstorm/projectstorm</a></strong></div><div>ProjectStorm! Contribute to thegreatstorm/projectstorm development by creating an account on GitHub.</div></blockquote>
Author
Owner

@JimTR commented on GitHub (Jul 19, 2020):

Can not do that as such as the code I have written is a plugin for some other code so I guess the best option is to abandon LGSM and write the functions I need. I didn't want to do that but for about 20 lines of bash code to be added to the core that could be undocumented and not advertised this appears to be my only option.

<!-- gh-comment-id:660684749 --> @JimTR commented on GitHub (Jul 19, 2020): Can not do that as such as the code I have written is a plugin for some other code so I guess the best option is to abandon LGSM and write the functions I need. I didn't want to do that but for about 20 lines of bash code to be added to the core that could be undocumented and not advertised this appears to be my only option.
Author
Owner

@Grimston commented on GitHub (Jul 19, 2020):

You could open an SSH connection using the correct user and use that to run the commands.

<!-- gh-comment-id:660725117 --> @Grimston commented on GitHub (Jul 19, 2020): You could open an SSH connection using the correct user and use that to run the commands.
Author
Owner

@JimTR commented on GitHub (Jul 20, 2020):

Ok that would work however I am trying to 'keep things simple' rather than introducing more code that needs to be maintained.
The code as is sets the apache user to the game server user, so I am the game server user ... therefore I should be able to run commands as that user. everything works as expected with the exception of tmux. I guess this to be design feature of tmux rather than a miss configuration of the user. On the other hand gnu screen works as expected. After testing game servers over the last 6 months using screen as the multiplexer I can report that there are no adverse effects of using screen over using tmux. in fact it is easier as you can specify a log file when you open the window where tmux it appears you have to create the file https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/functions/command_start.sh line 71.
looking on the net there are loads of posts saying that tmux is better than screen but to be fair this application is not using any of the 'advanced' functions of tmux I can not see the issue with

  1. adding a few lines of code to command_start.sh, command_stop.sh and check_status.sh to implement this
  2. either making it known or not, to add a variable to one of the game servers config files to use screen over tmux
  3. the code I have written defaults to tmux so really what is the problem
    @Grimston

I don't really see a need to move to screen, or even provide an option

why say that ? does it not fit the app your building ?

<!-- gh-comment-id:661059188 --> @JimTR commented on GitHub (Jul 20, 2020): Ok that would work however I am trying to 'keep things simple' rather than introducing more code that needs to be maintained. The code as is sets the apache user to the game server user, so I am the game server user ... therefore I should be able to run commands as that user. everything works as expected with the exception of tmux. I guess this to be design feature of tmux rather than a miss configuration of the user. On the other hand gnu screen works as expected. After testing game servers over the last 6 months using screen as the multiplexer I can report that there are no adverse effects of using screen over using tmux. in fact it is easier as you can specify a log file when you open the window where tmux it **appears** you have to create the file [https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/functions/command_start.sh](url) line 71. looking on the net there are loads of posts saying that tmux is better than screen but to be fair this application is not using any of the 'advanced' functions of tmux I can not see the issue with 1. adding a few lines of code to command_start.sh, command_stop.sh and check_status.sh to implement this 2. either making it known or not, to add a variable to one of the game servers config files to use screen over tmux 3. the code I have written defaults to tmux so really what is the problem @Grimston > I don't really see a need to move to screen, or even provide an option why say that ? does it not fit the app your building ?
Author
Owner

@Grimston commented on GitHub (Jul 21, 2020):

There is not much code for SSH to maintain as it's an extension for PHP already: SSH2 Manual or you can go for the full PHP route and use phpseclib

As for tmux and the console log, you do not need to create the file, LinuxGSM outputs multiple things to the file, so it's created manually, tmux is told to pipe >> it's output to the file a little later on.

From what I understand you are trying to rely on screens ability to share sessions with other users, which in my mind is a security flaw and really should be avoided.

My reason for not needing screen is a full SSH connection to the correct user, so it really has little effect on me if it's tmux or screen.
SSH Console

I did notice you have some Python scripts in your repository, why not take advantage of Python for it? This is an Old Project (Abandoned) that uses Python and provides a very basic WebUI for LinuxGSM.

<!-- gh-comment-id:661577762 --> @Grimston commented on GitHub (Jul 21, 2020): There is not much code for SSH to maintain as it's an extension for PHP already: [SSH2 Manual](https://www.php.net/manual/en/book.ssh2.php) or you can go for the full PHP route and use [phpseclib](http://phpseclib.sourceforge.net/) As for tmux and the console log, you do not need to create the file, LinuxGSM outputs multiple things to the file, so it's created manually, tmux is told to pipe `>>` it's output to the file a little later on. From what I understand you are trying to rely on screens ability to share sessions with other users, which in my mind is a security flaw and really should be avoided. My reason for not needing screen is a full SSH connection to the correct user, so it really has little effect on me if it's tmux or screen. ![SSH Console](https://cdn.discordapp.com/attachments/127498813903601664/733704282490142730/unknown.png) I did notice you have some Python scripts in your repository, why not take advantage of Python for it? This is an [Old Project](https://github.com/Grimston/LinuxGamePanel) (Abandoned) that uses Python and provides a very basic WebUI for LinuxGSM.
Author
Owner

@JimTR commented on GitHub (Jul 21, 2020):

You have that totally wrong I am not sharing any screen windows with anyone who would do that as you point out that is a security risk. I have looked at my repository and can see no python scripts at all.
program flow as follows :
Apache Request to start game server
php shell_exec or passthro starts the server in a multiplexer window
php then reads the console log file and processes the output which is then rendered to a web page
user then has the ability to send data to the multiplexer window via a form
currently that sent data is sanitised to only allow certain commands to sent to the multiplexer window
if successful the data is sent to multiplexer window and executed (tmux sendkeys or screen stuff) and the web page is updated



The php code also requests auth to the page (login) and if you want to have a go try here , which I guess clears up how I'm using the script and if the security issues that may arise


Why I wont use ssh is as follows I have a client that is on a server where they are not granted ssh access all they have is a file manager & cron manager ... I copied all the required game server files to their web space rather than installing the game via <server_name> i, got the supplier to add all dependences (that took a week or 2 before they would) then invoked the game via a php script all went well until the tmux issue switched to screen & problem solved.
I have tried to get the client to host his games on one of my servers which are not as restrictive but he does not wish to do that even tho the result would be better, that said some one else in the same position could hit the same problem

<!-- gh-comment-id:661799476 --> @JimTR commented on GitHub (Jul 21, 2020): You have that totally wrong I am not sharing any screen windows with anyone who would do that as you point out that is a security risk. I have looked at my repository and can see no python scripts at all. program flow as follows : <b>Apache Request to start game server php shell_exec or passthro starts the server in a multiplexer window php then reads the console log file and processes the output which is then rendered to a web page user then has the ability to send data to the multiplexer window via a form currently that sent data is sanitised to only allow certain commands to sent to the multiplexer window if successful the data is sent to multiplexer window and executed (tmux sendkeys or screen stuff) and the web page is updated</b></br> <img src="https://i.imgur.com/ZjXbZky.png"/> The php code also requests auth to the page (login) and if you want to have a go try <a href="https://warmmail.co.uk/console.php?id=cssserver">here</a> , which I guess clears up how I'm using the script and if the security issues that may arise<br><br> Why I wont use ssh is as follows I have a client that is on a server where they are not granted ssh access all they have is a file manager & cron manager ... I copied all the required game server files to their web space rather than installing the game via <server_name> i, got the supplier to add all dependences (that took a week or 2 before they would) then invoked the game via a php script all went well until the tmux issue switched to screen & problem solved. I have tried to get the client to host his games on one of my servers which are not as restrictive but he does not wish to do that even tho the result would be better, that said some one else in the same position could hit the same problem
Author
Owner

@akeljo commented on GitHub (Mar 28, 2022):

I'm not sure if this will help you. However I ran into your problem while researching mine.

sudo -u $user /home/$user/csgoserver details

Solved my problem of trying to start and stop the server from another screen/tmux session

<!-- gh-comment-id:1081120704 --> @akeljo commented on GitHub (Mar 28, 2022): I'm not sure if this will help you. However I ran into your problem while researching mine. sudo -u $user /home/$user/csgoserver details Solved my problem of trying to start and stop the server from another screen/tmux session
Author
Owner

@JimTR commented on GitHub (Mar 29, 2022):

changing PHP to fpm fixed it

<!-- gh-comment-id:1081945042 --> @JimTR commented on GitHub (Mar 29, 2022): changing PHP to fpm fixed it
Author
Owner

@github-actions[bot] commented on GitHub (Jun 4, 2023):

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

<!-- gh-comment-id:1575275567 --> @github-actions[bot] commented on GitHub (Jun 4, 2023): This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Sign in to join this conversation.
No labels
Atomic
Epic
cannot reproduce
command: backup
command: console
command: debug
command: details
command: fast-dl
command: install
command: mods
command: monitor
command: post-details
command: restart
command: send
command: start
command: stop
command: update
command: update-lgsm
command: validate
command: wipe
distro: AlmaLinux
distro: Arch Linux
distro: CentOS
distro: Debian
distro: Fedora
distro: RedHat
distro: Rocky Linux
distro: Ubuntu
distro: openSUSE
engine: goldsrc
engine: source
game: 7 Days to Die
game: ARMA 3
game: Ark: Survival Evolved
game: Assetto Corsa
game: Avorion
game: BATTALION: Legacy
game: Barotrauma
game: Battalion 1944
game: Battlefield 1942
game: Black Mesa: Deathmatch
game: Blade Symphony
game: Call of Duty 2
game: Call of Duty 4
game: Call of Duty: United Offensive
game: Counter-Strike 1.6
game: Counter-Strike 2
game: Counter-Strike: Global Offensive
game: Counter-Strike: Source
game: Day of Infamy
game: Dayz
game: Death Match Classic
game: Don't Starve Together
game: ET: Legacy
game: Eco
game: Factorio
game: Factorio
game: Garry's Mod
game: Half-Life
game: Hurtword
game: Insurgecy
game: Insurgecy
game: Insurgency: Sandstorm
game: Just Cause 3
game: Killing Floor
game: Killing Floor 2
game: Left 4 Dead 2
game: Minecraft
game: Minecraft Bedrock
game: Mordhau
game: Multi Theft Auto
game: Mumble
game: Natural Selection 2
game: No More Room in Hell
game: Pavlov VR
game: Post Scriptum
game: Project Zomboid
game: Quake 3
game: QuakeWorld
game: Red Orchestra: Ostfront 41-45
game: Return to Castle Wolfenstein
game: Rising World
game: Rust
game: San Andreas Multiplayer
game: Satisfactory
game: Soldat
game: Soldier of Fortune 2
game: Squad
game: Squad 44
game: Starbound
game: Stationeers
game: Sven Co-op
game: Team Fortress 2
game: Teamspeak 3
game: Teeworlds
game: Terraria
game: The Front
game: Unreal Tournament 2004
game: Unreal Tournament 3
game: Unreal Tournament 99
game: Unturned
game: Valheim
game: Wurm Unlimited
game: Zombie Master Reborn
game: label missing
good first issue
help wanted
info: alerts
info: dependency
info: docker
info: docs
info: email
info: query
info: steamcmd
info: systemd
info: tmux
info: website
info: website
needs more info
outcome: duplicate
outcome: issue resolved
outcome: issue resolved
outcome: issue unresolved
outcome: pr accepted
outcome: pr rejected
outcome: unconfirmed
outcome: wontfix
outcome: wrong forum
potential-duplicate
priority
pull-request
type: bug
type: feature
type: feature
type: feature request
type: game server request
type: refactor
waiting response
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LinuxGSM#2114
No description provided.