You are not logged in.

#1 2018-06-14 12:06:50

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

[SOLVED]System call waiting for user input

I would like to write a small little c program to connect to a vpn for me and automate a large portion of the process however connecting to the vpn service requires me to input several different things like whether I want to send a message to my phone for a temporary password or something like that. It also asks for my username and a few other things. I'm wondering if there is a way to have a separate file that I can send in as user input?
Example of connecting

$ openconnect vpn.service
POST https://vpn.service/
Connected to someIpAddress
SSL negotiation with vpn.service
Connected to HTTPS on vpn.service
XML POST enabled 
Group: USER IN #1
Username: USER IN #2
Password:  USER IN #3
Password:   USER IN #4

Last edited by jbenge1 (2018-06-15 18:20:12)


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#2 2018-06-14 12:13:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]System call waiting for user input

What does this have to do with writing a c program to connect.  Are you going to write your own program to connect, or do you want to use openconnect and feed input into it from a file?  For openconnect, just read the man page, all those inputs can be specified on the command line.

Last edited by Trilby (2018-06-14 12:15:00)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-06-14 16:58:41

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: [SOLVED]System call waiting for user input

the idea of the program is to make my life a little easier so I have to type less because I'm lazy when it comes to certain things. And I would like to use openconnect and feed it info from another file depending on whihc user is connected

//here's the general idea

int main()
{
    //read in file with users credentials
    printf("user %s attempting to connect to University VPN\n", userName);
    int connectRC = system("openconnect vpn.arizona.edu"); //here group will be something like 1-UASSLClient or 2-Engineering or Optical Science
                                                                                               // however this is also where we are looking for standard input
    //check for nonzero connectRC
}

"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#4 2018-06-14 17:11:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]System call waiting for user input

A C program to just call "system" makes no sense at all.  Use a script.  And again, there is no need to read the credentials from a file - just put them on the openconnect command line either in a script, or perhaps even just an alias.  E.g.,:

#!/bin/sh

openconnect \
   -g $group_name \
   -u $user_name \
   vpn.arizona.edu

Read the man page for other flags for passwords, certificates, etc.

Last edited by Trilby (2018-06-14 17:13:59)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-06-14 18:01:46

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: [SOLVED]System call waiting for user input

I apologise if this comes off as rude (I am not intending to be rude!!) however I have tried this (probably should've mentioned this in my intital post) and it yields errors in both an alias and a shell script hence the c program for a system call. I wouldn't be here had I not tried that.

Edit: I also have a dual authentication method thus I must enter my password and then the second type of user authentication as a second password

Last edited by jbenge1 (2018-06-14 18:08:49)


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#6 2018-06-14 18:32:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]System call waiting for user input

jbenge1 wrote:

it yields errors in both an alias and a shell script hence the c program for a system call

Then the C code will not work either, it will only be harder to debug.

But what are these errors?  Does open connect work with those parameters when used on the command line directly?  If so it will work in a script or alias.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2018-06-14 19:43:09

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: [SOLVED]System call waiting for user input

It does work from the command line yes

$ sudo openconnect vpn.arizona.edu
POST https://vpn.arizona.edu/
Connected to IP Address
SSL negotiation with vpn.arizona.edu
Connected to HTTPS on vpn.arizona.edu
XML POST enabled
VPN requires enrollment in NetID+. Enter push, phone, sms, or passcode for 
“NETID+Method”
GROUP: [1-UASSLClient|2-Engineering|3-COMVPN|4-COPH|5-Nutrition|6-Communications|7-BIO5|8-UAC|9-Law|Optical Science|UASSL-2Factor]:1-UASSLClient
POST https://vpn.arizona.edu/
XML POST enabled
VPN requires enrollment in NetID+. Enter push, phone, sms, or passcode for 
“NETID+Method”
Username:user
Password:
Password:
POST https://vpn.arizona.edu/
Got CONNECT response: HTTP/1.1 200 OK
CSTP connected. DPD 30, Keepalive 20

however trying to pass in group and user as a parameter yields

POST https://vpn.arizona.edu/1-UASSLClient
Connected to 206.207.228.1:443
SSL negotiation with vpn.arizona.edu
Connected to HTTPS on vpn.arizona.edu
XML POST enabled
Invalid host entry. Please re-enter.

I imagine because I am entering the group incorrectly? and I would much rather have a script I was just running out of ideas as well as I imagined a c program is much more scalable should I need more functionality at some point. But again I would much prefer a script or alias


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#8 2018-06-14 21:21:44

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]System call waiting for user input

Trilby wrote:

Does open connect work with those parameters when used on the command line directly?

You only showed using it interactively, not passing the command line parameters that I've now referred to three times (or is it four).  In the second code block you didn't show the command at all.  Did you use openconnect's command line options, or did you just add the group to the url?

Last edited by Trilby (2018-06-14 21:28:17)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2018-06-15 04:42:46

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: [SOLVED]System call waiting for user input

 
openconnect -g 1-UASSLClient -u jbenge1 vpn.arizona.edu

Is how I used the command line parameters


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#10 2018-06-15 07:27:13

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED]System call waiting for user input

You could try to add https:// before your host and then try with and without appending the group to it.

Last edited by progandy (2018-06-15 07:28:29)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#11 2018-06-15 14:07:29

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: [SOLVED]System call waiting for user input

this gives the same error when trying in to pass in the command line parameters unfortunatley


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#12 2018-06-15 14:33:05

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED]System call waiting for user input


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#13 2018-06-15 18:19:54

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: [SOLVED]System call waiting for user input

Thanks progandy this fixed the issue!


"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

Board footer

Powered by FluxBB