• Print

Author Topic: fileExec across srcds instances?  (Read 6363 times)

0 Members and 1 Guest are viewing this topic.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
fileExec across srcds instances?
« on: March 29, 2015, 05:31:52 am »
Does fileExec (or I guess in this case, the file I/O subsystem in lua) have vision across srcds instances on the same physical box?  I'm trying to juryrig a universal ban management system by executing the banned_user and banned_ip cfg files from the different instances I have running, but this (for example...)

ULib.execFile( "/home/steam/sb1/garrysmod/cfg/banned_user.cfg" )

generates Called execFile with invalid file!

Looking at the source, I'm thinking file.Exists potentially can't peek outside of it's directory jail?

Thanks,
Mike

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: fileExec across srcds instances?
« Reply #1 on: March 29, 2015, 09:56:28 am »
It's very likely that you can't read outside of the garrysmod folder, but I would test yourself (I can't remember lol). Keep in mind that directories are based off the "Garrysmod" folder by default. So, try just using file.Exists and see if you can get it to recognize the file:

Code: Lua
  1. print( file.Exists( "../../sb1/garrysmod/cfg/banned_user.cfg", "GAME" ) )
  2.  

(While keeping your path relative to your garrysmod folder, of course.)

If that manages to print true, you can then go a step further and make sure the file contents can be read:

Code: Lua
  1. print( file.Read( "../../sb1/garrysmod/cfg/banned_user.cfg", "GAME" ) )
  2.  

Then if THAT works, you should be able to use ULib.execFile without issue. Hope that helps!
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: fileExec across srcds instances?
« Reply #2 on: March 29, 2015, 11:11:27 am »
Nope, I had tested exactly that...  doesn't look like I can climb out of the directory tree past the g*mod folder.  Was hoping there was an undocumented approach, but of course that would be a security hole.

I can live with cron jobs moving the ban files, or just pull the plug and deploy Sourcebans.  Thanks for the help.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: fileExec across srcds instances?
« Reply #3 on: March 29, 2015, 12:20:29 pm »
Ok, I'm going around and around on this.  I must be doing something stupid.

Code: [Select]
local files, directories = file.Find("bancfg/*", "DATA")
for _, f in pairs(files) do
   ULib.execFile( 'data/bancfg/'..f, "GAME" )
end
--RunConsoleCommand("writeid")
ULib.consoleCommand( "writeid\n" )

inside ../garrysmod/data/bancfg are a series of banned_user.cfg and banned_ip.cfg files that I've copied from other servers.
Everything executes without error.  I can put print statements in and see the correct file path.  If I add extraneous chars to the file path, it throws the expected "invalid cfg file" message.  However, the banid statements inside the cfg files do not appear to be executing.  What am I doing wrong?

Thanks.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: fileExec across srcds instances?
« Reply #4 on: March 29, 2015, 01:25:37 pm »
You can run multiple servers from the same installation (same srcds.exe)
They will then share addons/data/and the banned users files.

Make sure if you do it this way that all of the servers should have the same addons.

Also, you can create symbolic links to have more than one installation share a single folder. I did this once to have multiple servers share a data folder and it worked great!

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: fileExec across srcds instances?
« Reply #5 on: March 29, 2015, 04:04:12 pm »
Thanks Pres.  All different gamemodes though, so I can't share at that level.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: fileExec across srcds instances?
« Reply #6 on: March 29, 2015, 05:21:10 pm »
I think you can do symbolic links for files too, not just directories.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: fileExec across srcds instances?
« Reply #7 on: March 29, 2015, 07:33:29 pm »
But to answer your original question, it's likely because you're trying to treat the parameters in "our" ULib.execFile command like "Gmod's" findFile.
2nd parameter of Gmod findfile tells it where to base it's start point (ie, data, game, ... ) as you know
2nd parameter of our exec is the queue name for ULib.namedQueueFunctionCall to use.
Leave it blank, delete the , "GAME" in your execfile statement and you'll likely get farther.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: fileExec across srcds instances?
« Reply #8 on: March 29, 2015, 08:30:01 pm »
Turns out it's working as expected -- just needed a player to spawn in to kick things off.  <palm to face>

Thanks!   :)

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: fileExec across srcds instances?
« Reply #9 on: March 29, 2015, 08:33:52 pm »
Turns out it's working as expected -- just needed a player to spawn in to kick things off.  <palm to face>

Thanks!   :)

Are you talking about being able to read files before the <garrysmod> tree directory, or something else?
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: fileExec across srcds instances?
« Reply #10 on: March 30, 2015, 07:04:44 am »
Are you talking about being able to read files before the <garrysmod> tree directory, or something else?

Sorry, to clarify -- I wasn't able to read above the garrysmod directory (which, from a basic security perspective, I wouldn't expect I could).  However, after building a small shell script to copy my banned_*.cfg files around to my various instances (dropping them into /data), I created a simple lua script to exec those cfg's on a timer.  It was that piece I was struggling with --- everything appeared to be running as expected without errors, but the banned statements didn't "take" and show up when calling listid until someone actually joined the server  (odd, since I'm issuing a writeid after I exec the cfgs... but not something I'm going to sweat).

« Last Edit: March 30, 2015, 07:13:23 am by Buzzkill-THABB »

  • Print