From 65d4721f73649e9d7556e4ed52bc776d4458b2fd Mon Sep 17 00:00:00 2001 From: Siddhant085 Date: Tue, 28 Jun 2016 20:55:34 +0530 Subject: [PATCH 1/5] removed the common code from steam-shell.pike --- tools/steam-shell.pike | 78 +++--------------------------------------- 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/tools/steam-shell.pike b/tools/steam-shell.pike index 7470e7a..ada1b42 100755 --- a/tools/steam-shell.pike +++ b/tools/steam-shell.pike @@ -23,6 +23,7 @@ constant cvs_version="$Id: debug.pike.in,v 1.1 2008/03/31 13:39:57 exodusd Exp $"; inherit "applauncher.pike"; +inherit "client.pike"; #define OBJ(o) _Server->get_module("filepath:tree")->path_to_object(o) Stdio.Readline readln; @@ -184,7 +185,9 @@ object handler, conn; mapping myarray; int main(int argc, array(string) argv) { - options=init(argv); + options = ([ "file":"/etc/shadow" ]); + options = options + init(argv); + options->historyfile=getenv("HOME")+"/.steam_history"; _Server=conn->SteamObj(0); users=_Server->get_module("users"); me = users->lookup(options->user); @@ -263,79 +266,6 @@ int main(int argc, array(string) argv) handler->add_input_line("exit"); } -mapping init(array argv) -{ - mapping options = ([ "file":"/etc/shadow" ]); - - array opt=Getopt.find_all_options(argv,aggregate( - ({"file",Getopt.HAS_ARG,({"-f","--file"})}), - ({"host",Getopt.HAS_ARG,({"-h","--host"})}), - ({"user",Getopt.HAS_ARG,({"-u","--user"})}), - ({"port",Getopt.HAS_ARG,({"-p","--port"})}), - )); - - options->historyfile=getenv("HOME")+"/.steam_history"; - - foreach(opt, array option) - { - options[option[0]]=option[1]; - } - if(!options->host) - options->host="127.0.0.1"; - if(!options->user) - options->user="root"; - if(!options->port) - options->port=1900; - else - options->port=(int)options->port; - - string server_path = "/usr/local/lib/steam"; - - master()->add_include_path(server_path+"/server/include"); - master()->add_program_path(server_path+"/server/"); - master()->add_program_path(server_path+"/conf/"); - master()->add_program_path(server_path+"/spm/"); - master()->add_program_path(server_path+"/server/net/coal/"); - - conn = ((program)"client_base.pike")(); - - int start_time = time(); - - werror("Connecting to sTeam server...\n"); - while ( !conn->connect_server(options->host, options->port) ) - { - if ( time() - start_time > 120 ) - { - throw (({" Couldn't connect to server. Please check steam.log for details! \n", backtrace()})); - } - werror("Failed to connect... still trying ... (server running ?)\n"); - sleep(10); - } - - ping(); - if(lower_case(options->user) == "guest") - return options; - - mixed err; - int tries=3; - //readln->set_echo( 0 ); - do - { - pw = Input.read_password( sprintf("Password for %s@%s", options->user, - options->host), "steam" ); - //pw=readln->read(sprintf("passwd for %s@%s: ", options->user, options->host)); - } - while((err = catch(conn->login(options->user, pw, 1))) && --tries); - //readln->set_echo( 1 ); - - if ( err != 0 ) - { - werror("Failed to log in!\nWrong Password!\n"); - exit(1); - } - return options; -} - mapping assign(object conn, object _Server, object users) { return ([ From e28e2f3ea19ee378cec67262d53f8b02c3e79cbe Mon Sep 17 00:00:00 2001 From: Siddhant085 Date: Tue, 28 Jun 2016 21:14:57 +0530 Subject: [PATCH 2/5] removed the common code for debug.pike --- tools/debug.pike | 79 +++--------------------------------------------- 1 file changed, 4 insertions(+), 75 deletions(-) diff --git a/tools/debug.pike b/tools/debug.pike index ef31eef..e1821c3 100755 --- a/tools/debug.pike +++ b/tools/debug.pike @@ -23,6 +23,7 @@ constant cvs_version="$Id: debug.pike.in,v 1.1 2008/03/31 13:39:57 exodusd Exp $"; inherit "applauncher.pike"; +inherit "client.pike"; Stdio.Readline readln; mapping options; @@ -88,7 +89,9 @@ object handler, conn; int main(int argc, array(string) argv) { - options=init(argv); + options = ([ "file":"/etc/shadow" ]); + options= options + init(argv); + options->historyfile=getenv("HOME")+"/.steam_history"; _Server=conn->SteamObj(0); users=_Server->get_module("users"); all = assign(conn,_Server,users); @@ -515,80 +518,6 @@ int main(int argc, array(string) argv) handler->add_input_line("exit"); } -mapping init(array argv) -{ - mapping options = ([ "file":"/etc/shadow" ]); - - array opt=Getopt.find_all_options(argv,aggregate( - ({"file",Getopt.HAS_ARG,({"-f","--file"})}), - ({"host",Getopt.HAS_ARG,({"-h","--host"})}), - ({"user",Getopt.HAS_ARG,({"-u","--user"})}), - ({"port",Getopt.HAS_ARG,({"-p","--port"})}), - )); - - options->historyfile=getenv("HOME")+"/.steam_history"; - - foreach(opt, array option) - { - options[option[0]]=option[1]; - } - if(!options->host) - options->host="127.0.0.1"; - if(!options->user) - options->user="root"; - if(!options->port) - options->port=1900; - else - options->port=(int)options->port; - - string server_path = "/usr/local/lib/steam"; - //change this to working directory - - master()->add_include_path(server_path+"/server/include"); - master()->add_program_path(server_path+"/server/"); - master()->add_program_path(server_path+"/conf/"); - master()->add_program_path(server_path+"/spm/"); - master()->add_program_path(server_path+"/server/net/coal/"); - - conn = ((program)"client_base.pike")(); - - int start_time = time(); - - werror("Connecting to sTeam server...\n"); - while ( !conn->connect_server(options->host, options->port) ) - { - if ( time() - start_time > 120 ) - { - throw (({" Couldn't connect to server. Please check steam.log for details! \n", backtrace()})); - } - werror("Failed to connect... still trying ... (server running ?)\n"); - sleep(10); - } - - ping(); - if(lower_case(options->user) == "guest") - return options; - - mixed err; - int tries=3; - //readln->set_echo( 0 ); - do - { - pw = Input.read_password( sprintf("Password for %s@%s", options->user, - options->host), "steam" ); - //pw=readln->read(sprintf("passwd for %s@%s: ", options->user, options->host)); - } - while((err = catch(conn->login(options->user, pw, 1))) && --tries); - //readln->set_echo( 1 ); - - if ( err != 0 ) - { - werror("Failed to log in!\nWrong Password!\n"); - exit(1); - } - return options; -} - mapping assign(object conn, object _Server, object users) { return ([ From 5f3bc0711aeb41bebe618aa48f3735f3db852233 Mon Sep 17 00:00:00 2001 From: Siddhant085 Date: Tue, 28 Jun 2016 21:16:27 +0530 Subject: [PATCH 3/5] Added the check for -f option in client.pike --- tools/client.pike | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/client.pike b/tools/client.pike index d8a2528..eacc7b8 100755 --- a/tools/client.pike +++ b/tools/client.pike @@ -39,6 +39,7 @@ mapping init(array argv) mapping options = ([ ]); array opt=Getopt.find_all_options(argv,aggregate( + ({"file",Getopt.HAS_ARG,({"-f","--file"})}), ({"host",Getopt.HAS_ARG,({"-h","--host"})}), ({"user",Getopt.HAS_ARG,({"-u","--user"})}), ({"port",Getopt.HAS_ARG,({"-p","--port"})}), From 66b1a59d9fa793e7a2a0240ffe6e3b3a6ee3167e Mon Sep 17 00:00:00 2001 From: Siddhant085 Date: Tue, 28 Jun 2016 21:57:22 +0530 Subject: [PATCH 4/5] removed the common code from edit.pike --- tools/edit.pike | 90 ++++--------------------------------------------- 1 file changed, 7 insertions(+), 83 deletions(-) diff --git a/tools/edit.pike b/tools/edit.pike index 3e7512f..128ac49 100755 --- a/tools/edit.pike +++ b/tools/edit.pike @@ -23,6 +23,7 @@ constant cvs_version="$Id: edit.pike.in,v 1.0 2010/09/15 14:19:52 martin Exp $"; inherit "applauncher.pike"; +inherit "client.pike"; //inherit "/usr/local/lib/steam/server/modules/groups.pike"; void ping(string host, string port, string user, string|void pw) { @@ -51,13 +52,15 @@ object conn; mapping conn_options = ([]); object _Server,user_obj,file; array(object) gp; +mapping options = ([ ]); int main(int argc, array(string) argv) { - - + // program pGroup = (program)"/classes/Group.pike"; - mapping options=init(argv); + options=init(argv); + options->file = argv[-1]; + ping(options->host, options->port, options->user, pw); // gp=_Server->get_module("groups")->lookup("helloworld"); _Server=conn->SteamObj(0); user_obj = _Server->get_module("users")->lookup(options->user); @@ -117,83 +120,4 @@ void get_file_object() } if (file->get_class() == "Link") file = file->get_link_object(); -} - - mapping options = ([ ]); -mapping init(array argv) -{ - - array opt=Getopt.find_all_options(argv,aggregate( - ({"host",Getopt.HAS_ARG,({"-h","--host"})}), - ({"user",Getopt.HAS_ARG,({"-u","--user"})}), - ({"port",Getopt.HAS_ARG,({"-p","--port"})}), - )); - - foreach(opt, array option) - { - options[option[0]]=option[1]; - } - if(!options->host) - options->host="127.0.0.1"; - if(!options->user) - options->user="root"; - if(!options->port) - options->port=1900; - else - options->port=(int)options->port; - - options->file = argv[-1]; - - string server_path = "/usr/local/lib/steam"; - - master()->add_include_path(server_path+"/server/include"); - master()->add_program_path(server_path+"/server/"); - master()->add_program_path(server_path+"/server/modules/groups.pike"); - master()->add_program_path(server_path+"/conf/"); - master()->add_program_path(server_path+"/spm/"); - master()->add_program_path(server_path+"/server/net/coal/"); - - conn = ((program)"client_base.pike")(); -// groups_pgm = ((program)"groups.pike")(); - int start_time = time(); - - werror("Connecting to sTeam server...\n"); - while ( !conn->connect_server(options->host, options->port) ) - { - if ( time() - start_time > 120 ) - { - throw (({" Couldn't connect to server. Please check steam.log for details! \n", backtrace()})); - } - werror("Failed to connect... still trying ... (server running ?)\n"); - sleep(10); - } - - if(lower_case(options->user) == "guest") - { - ping(options->host, options->port, options->user); - return options; - } - - mixed err; - string pw; - int tries=3; - //readln->set_echo( 0 ); - do - { - pw = Input.read_password( sprintf("Password for %s@%s", options->user, - options->host), "steam" ); -// pw ="steam"; - //pw=readln->read(sprintf("passwd for %s@%s: ", options->user, options->host)); - } - while((err = catch(conn->login(options->user, pw, 1))) && --tries); - //readln->set_echo( 1 ); - - if ( err != 0 ) - { - werror("Failed to log in!\nWrong Password!\n"); - exit(1); - } - ping(options->host, options->port, options->user, pw); - return options; -} - +} \ No newline at end of file From 01f372505311adef0145fdf606a295c894719d06 Mon Sep 17 00:00:00 2001 From: Siddhant085 Date: Tue, 28 Jun 2016 21:58:08 +0530 Subject: [PATCH 5/5] made variable pw global in client.pike --- tools/client.pike | 2 +- tools/debug.pike | 2 +- tools/steam-shell.pike | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/client.pike b/tools/client.pike index eacc7b8..45d98a6 100755 --- a/tools/client.pike +++ b/tools/client.pike @@ -33,6 +33,7 @@ void ping() object conn; mapping options = ([ ]); +string pw; mapping init(array argv) { @@ -86,7 +87,6 @@ mapping init(array argv) return options; mixed err; - string pw; int tries=3; //readln->set_echo( 0 ); do diff --git a/tools/debug.pike b/tools/debug.pike index e1821c3..d9a3a9a 100755 --- a/tools/debug.pike +++ b/tools/debug.pike @@ -28,7 +28,7 @@ inherit "client.pike"; Stdio.Readline readln; mapping options; int flag=1,c=1; -string pw,str; +string str; class Handler { diff --git a/tools/steam-shell.pike b/tools/steam-shell.pike index ada1b42..f54650f 100755 --- a/tools/steam-shell.pike +++ b/tools/steam-shell.pike @@ -29,7 +29,7 @@ inherit "client.pike"; Stdio.Readline readln; mapping options; int flag=1,c=1; -string pw,str; +string str; object me; protected class StashHelp {