Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Change Linux-User password via gdc  (Read 6249 times)
Stefan S.
Posts: 90


« on: July 06, 2022, 03:38:03 pm »

Hello,

has anyone an idea to change the Linux-User Password via a GDC-Application?
The user should not use a Terminal-Application to enter passwd.

We are looking for a little Script which can be created and executed within the Application.

Any idea?

Thanks Stefan.
Daniele A.
Posts: 28


« Reply #1 on: July 06, 2022, 04:27:36 pm »

Hi Stefan

the following snippet works for me !


let wk_log_changepwd = g_tmpdir clipped,g_separator, "changepasswd_",
                       g_s_pid using "<<<<<<<<<<<&", ".log"

let wk_cmd = 'echo -e "',ri.password_old clipped,'\n',
             ri.password_new clipped,'\n',
             ri.password_cnf clipped,'" | passwd  &>',wk_log_changepwd

run wk_cmd returning wk_exit_code

bye
Reuben B.
Four Js
Posts: 1046


« Reply #2 on: July 07, 2022, 12:28:19 am »

An area you can explore is to utilise GDC Connection Strings in your GDC Shortcut settings.  See step 10 here http://4js.com/online_documentation/fjs-gdc-manual-html/#gdc-topics/t_gdc_applications_shortcuts_creating_direct.html.  The technique is to add extra entries for the text you expect to appear when you are required to change your password, and have the GDC respond by prompting for the new password and sending it.  I can't recall if it was a technique that was eventually used in production, or if it fell into the thats interesting but it does not do quite what we need it to do category.  The GDC Connection strings were designed to manage the connection, and this is going beyond their initial design criteria hence the hesitation.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Stefan S.
Posts: 90


« Reply #3 on: July 07, 2022, 08:58:43 am »

Hi,

thanks.
I tired the command with "echo -e"....
this is working fine.
the Result of the command I write in a file to show the user a message, if passwd raises an error....
Code
  1. #------------------------------------------------------------------------------
  2. #------------------------------------------------------------------------------
  3. function user_passwd(lo_alt, lo_neu)
  4. define lo_alt          string,
  5.       lo_neu          string,
  6.       lo_ch           base.Channel,
  7.       lo_stm          string,
  8.       lo_result       string,
  9.       lo_logdatei     string,
  10.       lo_egal         string,
  11.       lo_pw_geaendert boolean,
  12.       lo_errorlevel   string
  13.  
  14.   -- ! | ? & % " ' \ sind nicht erlaubt!
  15.  
  16.   let lo_alt          = lo_alt clipped
  17.   let lo_neu          = lo_neu clipped
  18.   let lo_pw_geaendert = false
  19.   let lo_errorlevel   = ""
  20.  
  21.   let lo_logdatei = vlogin clipped, "_passwd.log"
  22.   let lo_logdatei = lo_logdatei clipped
  23.   let lo_egal     = os.path.delete(lo_logdatei)
  24.  
  25.   let lo_stm = "echo -e '", lo_alt, "\\n", lo_neu, "\\n", lo_neu, "' | passwd 1>>", lo_logdatei, " 2>> ", lo_logdatei
  26.   run lo_stm returning lo_errorlevel
  27.  
  28.   if lo_errorlevel = 0 then
  29.      let lo_pw_geaendert = true
  30.   else
  31.      let lo_pw_geaendert = false
  32.   end if
  33.  
  34.   let lo_ch = base.channel.create()
  35.   call lo_ch.openFile(lo_logdatei, "r")
  36.   call lo_ch.setdelimiter("")
  37.   while lo_ch.read ([lo_result])
  38.      if lo_result matches "*Ändern des Passworts*" then
  39.         continue while
  40.      end if
  41.      if lo_result matches "*Ändern Passwort*" then
  42.         continue while
  43.      end if
  44.      display lo_result
  45.   end while
  46.   call lo_ch.close()
  47.  
  48.   let lo_egal = os.path.delete(lo_logdatei)
  49.  
  50.   if lo_pw_geaendert = true then
  51.      display "hat geklappt!!!!!"
  52.   else
  53.      display "hat NICHT geklappt!!!!!"
  54.   end if
  55.  
  56.  
  57. end function
  58. #------------------------------------------------------------------------------
  59. #------------------------------------------------------------------------------
Roland W.
Posts: 11


« Reply #4 on: July 07, 2022, 09:21:06 am »

Hi folks,

wouldn't it be better to use the openPipe() function instead of calling "run" as in this example? https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassChannel_example_2.html

Kind regards
Roland
Stefan S.
Posts: 90


« Reply #5 on: July 07, 2022, 11:17:21 am »

Hi Roland,

I tried the channel.openpipe before. But in the output Files I missed either the "success" part, or the "faild" part (not sure which one)

Stefan
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines