Adding bugs
This commit is contained in:
parent
1cf2bb2d78
commit
9cf2936d6f
7
TODO
7
TODO
@ -1,4 +1,4 @@
|
|||||||
$Amigan: phoned/TODO,v 1.2 2005/06/20 03:05:01 dcp1990 Exp $
|
$Amigan: phoned/TODO,v 1.3 2005/06/23 22:06:57 dcp1990 Exp $
|
||||||
TODO
|
TODO
|
||||||
For phoned:
|
For phoned:
|
||||||
*Handle conditions (write the glue) - Halfway done.
|
*Handle conditions (write the glue) - Halfway done.
|
||||||
@ -18,3 +18,8 @@ For scripts:
|
|||||||
|
|
||||||
For everything:
|
For everything:
|
||||||
*Write documentation
|
*Write documentation
|
||||||
|
|
||||||
|
OUTSTANDING BUGS:
|
||||||
|
*Certain race conditions (i.e. closing a socket during a blocking I/O call inside sendwr()) will leave mutexes open and the user logged in (or the servicing thread running entirely).
|
||||||
|
This needs to be fixed, either by detecting the system call interrupt or other means. Hopefully the IO call will exit in time, but we cannot hope for all things.
|
||||||
|
Fix this for good.
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* (C)2005, Dan Ponte
|
* (C)2005, Dan Ponte
|
||||||
* BSDL w/ advert.
|
* BSDL w/ advert.
|
||||||
*/
|
*/
|
||||||
/* $Amigan: phoned/include/phoned.h,v 1.26 2005/06/23 16:46:06 dcp1990 Exp $ */
|
/* $Amigan: phoned/include/phoned.h,v 1.27 2005/06/23 22:06:58 dcp1990 Exp $ */
|
||||||
#include <pcre.h> /* fugly, I know... */
|
#include <pcre.h> /* fugly, I know... */
|
||||||
#define VERSION "0.1"
|
#define VERSION "0.1"
|
||||||
#define LOGFILE "-"
|
#define LOGFILE "-"
|
||||||
@ -139,8 +139,7 @@ typedef struct mod_t {
|
|||||||
} modem_t;
|
} modem_t;
|
||||||
typedef enum stat {
|
typedef enum stat {
|
||||||
init = 0,
|
init = 0,
|
||||||
loginstage,
|
loggedin
|
||||||
pass
|
|
||||||
} states_t;
|
} states_t;
|
||||||
typedef struct si_t {
|
typedef struct si_t {
|
||||||
states_t st;
|
states_t st;
|
||||||
@ -194,6 +193,7 @@ void cid_handle(cid_t *c);
|
|||||||
void awaken_sel(void);
|
void awaken_sel(void);
|
||||||
void modem_wake(void);
|
void modem_wake(void);
|
||||||
void fillset(void);
|
void fillset(void);
|
||||||
|
char *sendwr(const char *str, char *bufferback, size_t howmuch);
|
||||||
login_t *check_logged_in(char *loginna, login_t *top);
|
login_t *check_logged_in(char *loginna, login_t *top);
|
||||||
short log_in_user(char *loginna, char *pass, login_t **lnt);
|
short log_in_user(char *loginna, char *pass, login_t **lnt);
|
||||||
login_t *add_to_login_list(char *loginna, login_t **toppt);
|
login_t *add_to_login_list(char *loginna, login_t **toppt);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* $Amigan: phoned/phonectl/phonectl.c,v 1.4 2005/06/23 21:38:58 dcp1990 Exp $ */
|
/* $Amigan: phoned/phonectl/phonectl.c,v 1.5 2005/06/23 22:07:01 dcp1990 Exp $ */
|
||||||
/* system includes */
|
/* system includes */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -59,9 +59,9 @@ int main(argc, argv)
|
|||||||
perror("conn");
|
perror("conn");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if(argc < 1) {
|
if(argc == 1) {
|
||||||
for(;;) {
|
while(!feof(stdin)) {
|
||||||
puts("phonectl> ");
|
fputs("phonectl> ", stdout);
|
||||||
fgets(buff, 1024, stdin);
|
fgets(buff, 1024, stdin);
|
||||||
nl = strchr(buff, '\n');
|
nl = strchr(buff, '\n');
|
||||||
if(nl != NULL) *nl = '\0';
|
if(nl != NULL) *nl = '\0';
|
||||||
@ -71,12 +71,12 @@ int main(argc, argv)
|
|||||||
}
|
}
|
||||||
write(s, buff, strlen(buff) + 1);
|
write(s, buff, strlen(buff) + 1);
|
||||||
read(s, buff, sizeof(buff));
|
read(s, buff, sizeof(buff));
|
||||||
puts(buff);
|
fputs(buff, stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write(s, argv[1], strlen(argv[1]) + 1);
|
write(s, argv[1], strlen(argv[1]) + 1);
|
||||||
read(s, buff, sizeof buff);
|
read(s, buff, sizeof buff);
|
||||||
puts(buff);
|
fputs(buff, stdout);
|
||||||
close(s);
|
close(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,31 @@ void stmod(str)
|
|||||||
pthread_mutex_unlock(&modemmx);
|
pthread_mutex_unlock(&modemmx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
char *sendwr(str, bufferback, howmuch)
|
||||||
|
const char *str;
|
||||||
|
char *bufferback;
|
||||||
|
size_t howmuch;
|
||||||
|
{
|
||||||
|
if(pthread_mutex_trylock(&modemmx) != 0 && pthread_mutex_trylock(&miomx) != 0) {
|
||||||
|
pthread_mutex_lock(&mpipemx);
|
||||||
|
write(modempipes[1], "G", 1);
|
||||||
|
pthread_mutex_unlock(&mpipemx);
|
||||||
|
pthread_mutex_lock(&modemmx);
|
||||||
|
write(modemfd, str, strlen(str) + 1);
|
||||||
|
write(modemfd, "\r\n", 3);
|
||||||
|
read(modemfd, bufferback, howmuch);
|
||||||
|
fgets(bufferback, howmuch, modem);
|
||||||
|
pthread_cond_signal(&mpcond);
|
||||||
|
pthread_mutex_unlock(&modemmx);
|
||||||
|
} else {
|
||||||
|
pthread_mutex_lock(&modemmx);
|
||||||
|
write(modemfd, str, strlen(str) + 1);
|
||||||
|
write(modemfd, "\r\n", 3);
|
||||||
|
fgets(bufferback, howmuch, modem);
|
||||||
|
pthread_mutex_unlock(&modemmx);
|
||||||
|
}
|
||||||
|
return bufferback;
|
||||||
|
}
|
||||||
void modem_wake(void)
|
void modem_wake(void)
|
||||||
{
|
{
|
||||||
if(pthread_mutex_trylock(&miomx) != 0) {
|
if(pthread_mutex_trylock(&miomx) != 0) {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* $Amigan: phoned/phoned/remote.c,v 1.11 2005/06/22 04:01:03 dcp1990 Exp $ */
|
/* $Amigan: phoned/phoned/remote.c,v 1.12 2005/06/23 22:07:02 dcp1990 Exp $ */
|
||||||
/* system includes */
|
/* system includes */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -228,8 +228,10 @@ char *parse_command(cmd, cont, s)
|
|||||||
rc = log_in_user(argvect[cpos], argvect[cpos + 1], &s->l);
|
rc = log_in_user(argvect[cpos], argvect[cpos + 1], &s->l);
|
||||||
cpos++;
|
cpos++;
|
||||||
if(rc == -1) {
|
if(rc == -1) {
|
||||||
|
s->st = loggedin;
|
||||||
RNF("501 LOGGEDIN: Already logged in.\n");
|
RNF("501 LOGGEDIN: Already logged in.\n");
|
||||||
} else if(rc) {
|
} else if(rc) {
|
||||||
|
s->st = loggedin;
|
||||||
RNF("501 LOGGEDIN: Logged in! Welcome!\n");
|
RNF("501 LOGGEDIN: Logged in! Welcome!\n");
|
||||||
} else if(!rc) {
|
} else if(!rc) {
|
||||||
RNF("514 LOGINFAIL: Login failed.\n");
|
RNF("514 LOGINFAIL: Login failed.\n");
|
||||||
@ -237,16 +239,29 @@ char *parse_command(cmd, cont, s)
|
|||||||
} else {
|
} else {
|
||||||
RNF("513 ERROR: Syntax error: Needs username and pass as arguments.\n");
|
RNF("513 ERROR: Syntax error: Needs username and pass as arguments.\n");
|
||||||
}
|
}
|
||||||
} else if(CHK("logout")) {
|
} else {
|
||||||
if(s->l != NULL) {
|
RNF("513 ERROR: No such command (perhaps not logged in?)\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case loggedin:
|
||||||
|
if(CHK("logout")) {
|
||||||
pthread_mutex_lock(&usermx);
|
pthread_mutex_lock(&usermx);
|
||||||
log_out_user(NULL, &s->l);
|
log_out_user(NULL, &s->l);
|
||||||
if(s->l == 0x0) usertop = 0;
|
if(s->l == 0x0) usertop = 0;
|
||||||
pthread_mutex_unlock(&usermx);
|
pthread_mutex_unlock(&usermx);
|
||||||
s->l = NULL;
|
s->l = NULL;
|
||||||
|
s->st = init;
|
||||||
RNF("502 LOGGEDOUT: User logged out.\n");
|
RNF("502 LOGGEDOUT: User logged out.\n");
|
||||||
|
} else if(CHK("stmodem")) {
|
||||||
|
if(argvect[++cpos] != NULL) {
|
||||||
|
char *tempbuf;
|
||||||
|
tempbuf = malloc(512 * sizeof(char));
|
||||||
|
memset(tempbuf, 0, 512 * sizeof(char));
|
||||||
|
sendwr(argvect[cpos], tempbuf, 512);
|
||||||
|
s->freeit = 1;
|
||||||
|
return tempbuf;
|
||||||
} else {
|
} else {
|
||||||
RNF("513 ERROR: Not logged in!\n");
|
RNF("513 ERROR: Wrong number of arguments.\n");
|
||||||
}
|
}
|
||||||
} else if(CHK("thandler")) {
|
} else if(CHK("thandler")) {
|
||||||
cid_t c;
|
cid_t c;
|
||||||
@ -294,10 +309,6 @@ char *parse_command(cmd, cont, s)
|
|||||||
RNF("513 ERROR: Unrecognised Command\n");
|
RNF("513 ERROR: Unrecognised Command\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case loginstage:
|
|
||||||
break;
|
|
||||||
case pass:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user