View previous topic :: View next topic |
Author |
Message |
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Thu Aug 28, 2008 23:26 Post subject: Beta Plugin: nwnx_system |
|
|
I've just completed a new plugin, nwnx_system which provides access to various system functions, and integrates the nwnx_resetplugin and nwnx_tmi plugin functionality.
Note that the DirList and FileCopy functions are not yet complete. The plugin is available in Subversion.
Code: | string DirList (string sDir);
int FileCopy (string sFrom, string sTo);
int FileDelete (string sFile);
int FileLink (string sFrom, string sTo);
int FileRename (string sFrom, string sTo);
int FileSymlink (string sFrom, string sTo);
struct CPUUsage GetProcessCPUUsage ();
int GetProcessMemoryUsage ();
int GetSystemTime ();
int GetTMILimit ();
void SetTMILimit (int nLimit);
void ShutdownServer (int nForce=0); |
Note that FileRename has UNIX semantics; it will overwrite the destination file. If you want to safely rename a file without overwriting, use FileLink() followed by FileDelete() after checking for the success of FileLink().
Acaos |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Fri Sep 05, 2008 23:45 Post subject: |
|
|
The possibilities for this are very exciting, but also potentially lethal for servers. Is it possible for hackers to use this if such functions were available only to DMs with scripted-in powers to use this sort of thing? This is assuming that the code itself that is not part of the plugin is watertight. |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Sat Sep 06, 2008 1:03 Post subject: |
|
|
If you are not cautious, then yes it is.
Get totally sure that person using this is person who should be.
Any conversation node should have extra GetIsDM check and I would check CDKEY and account too. _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Sat Sep 06, 2008 1:06 Post subject: |
|
|
The person in question would have to have the ability to set locals. The only thing I know with that capability other than the dm client is SIMTools, which checks cd key to confirm dm status. In other words, no, it isn't possible, unless your security coding is beyond poor. You do confirm dm logins against cd key, right?
I spose it's possible that DMFI allows local setting as well - I don't recall. In that case, you'd have a problem, since DMFI has a gaping security hole, though they are planning to fix it in the next release.
Funky |
|
Back to top |
|
|
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Sat Sep 06, 2008 5:58 Post subject: |
|
|
Yes, this is potentially quite dangerous, but no more so than the nwnx_leto plugin, since Leto has file manipulation and deletion functions as well.
Acaos |
|
Back to top |
|
|
scarface
Joined: 12 Jun 2005 Posts: 94 Location: Sweden
|
Posted: Sat Sep 06, 2008 18:15 Post subject: Re: Beta Plugin: nwnx_system |
|
|
acaos wrote: | I've just completed a new plugin, nwnx_system which provides access to various system functions, and integrates the nwnx_resetplugin and nwnx_tmi plugin functionality.
Note that the DirList and FileCopy functions are not yet complete. The plugin is available in Subversion.
Code: | string DirList (string sDir);
int FileCopy (string sFrom, string sTo);
int FileDelete (string sFile);
int FileLink (string sFrom, string sTo);
int FileRename (string sFrom, string sTo);
int FileSymlink (string sFrom, string sTo);
struct CPUUsage GetProcessCPUUsage ();
int GetProcessMemoryUsage ();
int GetSystemTime ();
int GetTMILimit ();
void SetTMILimit (int nLimit);
void ShutdownServer (int nForce=0); |
Note that FileRename has UNIX semantics; it will overwrite the destination file. If you want to safely rename a file without overwriting, use FileLink() followed by FileDelete() after checking for the success of FileLink().
Acaos |
How efficient ( or inefficient ) would it be to call GetProcessCPUUsage() & GetProcessMemoryUsage () every 6 seconds with a module heartbeat to display this info in game? |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Sat Sep 06, 2008 19:06 Post subject: |
|
|
@scarface: Those two functions seem fairly harmless. Why not try it yourself? Get some statistics about these new functions.
I wrote: | This is assuming that the code itself that is not part of the plugin is watertight. |
You've said that the plugin is dangerous if the code is NOT watertight, but I knew that anyway, we all do. And any scripter worth their salt (hopefully) knows how to make doubly sure that the person on the other end of the conversation is who it's meant to be.
So we're alright there.
Acaos' response was the most helpful, thank you. I will definitely be using at least some of these functions. |
|
Back to top |
|
|
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Sun Sep 07, 2008 22:53 Post subject: Re: Beta Plugin: nwnx_system |
|
|
scarface wrote: | How efficient ( or inefficient ) would it be to call GetProcessCPUUsage() & GetProcessMemoryUsage () every 6 seconds with a module heartbeat to display this info in game? |
Should be totally fine. We do that on Higher Ground, actually. They are quite lightweight.
Acaos |
|
Back to top |
|
|
scarface
Joined: 12 Jun 2005 Posts: 94 Location: Sweden
|
Posted: Sun Sep 07, 2008 23:23 Post subject: Re: Beta Plugin: nwnx_system |
|
|
acaos wrote: | scarface wrote: | How efficient ( or inefficient ) would it be to call GetProcessCPUUsage() & GetProcessMemoryUsage () every 6 seconds with a module heartbeat to display this info in game? |
Should be totally fine. We do that on Higher Ground, actually. They are quite lightweight.
Acaos |
Great thanks. |
|
Back to top |
|
|
Tsais
Joined: 18 Sep 2017 Posts: 6
|
Posted: Thu Oct 12, 2017 9:33 Post subject: |
|
|
Trying to use a simple DirList() but not having much luck. The function calls for a string parameter and I'm assuming I'd use a Linux pwd path, like:
Code: | string sPath = DirList("/opt/nwn/servervault/"); |
... but it only returns the path I'm using plus a lot of ".............................."
Tried using DirList("servervault") and several other variations - no luck.
Any ideas? |
|
Back to top |
|
|
|