kopia lustrzana https://github.com/Hamlib/Hamlib
Remove sys/time.h include from rig.h -- not needed
Remove redundant semicolon from rig_debug macro and fix rig_debug's without a semicolon Some more work on settings and password control -- still in work https://github.com/Hamlib/Hamlib/issues/813 https://github.com/Hamlib/Hamlib/issues/985pull/1031/head
rodzic
3096ad8b68
commit
81d0c3c768
|
@ -37,7 +37,6 @@
|
|||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <hamlib/config.h>
|
||||
#ifdef HAVE_PTHREAD
|
||||
#include <pthread.h>
|
||||
|
@ -3282,7 +3281,7 @@ extern HAMLIB_EXPORT_VAR(char) debugmsgsave3[DEBUGMSGSAVE_SIZE]; // last-2 debu
|
|||
#ifndef __cplusplus
|
||||
#ifdef __GNUC__
|
||||
// doing the debug macro with a dummy sprintf allows gcc to check the format string
|
||||
#define rig_debug(debug_level,fmt,...) do { snprintf(debugmsgsave2,sizeof(debugmsgsave2),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); add2debugmsgsave(debugmsgsave2); } while(0);
|
||||
#define rig_debug(debug_level,fmt,...) do { snprintf(debugmsgsave2,sizeof(debugmsgsave2),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); add2debugmsgsave(debugmsgsave2); } while(0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -3389,6 +3388,8 @@ extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t msec);
|
|||
extern HAMLIB_EXPORT(int) rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie, int cookie_len);
|
||||
|
||||
extern HAMLIB_EXPORT(int) rig_password(RIG *rig, const char *key1);
|
||||
extern HAMLIB_EXPORT(void) rig_password_generate_secret(char *pass,
|
||||
char result[HAMLIB_SECRET_LENGTH + 1]);
|
||||
|
||||
//extern HAMLIB_EXPORT(int)
|
||||
int longlat2locator HAMLIB_PARAMS((double longitude,
|
||||
|
|
|
@ -293,7 +293,7 @@ unsigned char *make_hash(char *arg)
|
|||
|
||||
char *rig_make_md5(char *pass)
|
||||
{
|
||||
unsigned char *hash = make_hash("password");
|
||||
unsigned char *hash = make_hash(pass);
|
||||
char *md5str = make_digest(hash, 16);
|
||||
return md5str;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ HAMLIB_EXPORT(void) rig_password_generate_secret(char *pass,
|
|||
|
||||
srand(product);
|
||||
|
||||
snprintf(newpass, sizeof(newpass) - 1, "%s\t%lu\n", pass, (long)rand());
|
||||
printf("debug=%s\n", newpass);
|
||||
snprintf(newpass, sizeof(newpass) - 1, "%s\t%lu\t%lu", pass, (long)rand(),time(NULL));
|
||||
//printf("debug=%s\n", newpass);
|
||||
char *md5str = rig_make_md5(newpass);
|
||||
|
||||
strncpy(result, md5str, HAMLIB_SECRET_LENGTH);
|
||||
|
@ -62,7 +62,7 @@ HAMLIB_EXPORT(void) rig_password_generate_secret(char *pass,
|
|||
printf("\nCan be used with rigctl --password [secret]\nOr can be place in ~/.hamlib_settings\n");
|
||||
}
|
||||
|
||||
#define TESTPASSWORD
|
||||
//#define TESTPASSWORD
|
||||
#ifdef TESTPASSWORD
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
|
@ -1042,7 +1042,6 @@ HAMLIB_EXPORT(int) rig_settings_save(char *setting, void *value,
|
|||
|
||||
int fd = mkstemp(template);
|
||||
close(fd);
|
||||
printf("template=%s\n",template);
|
||||
fptmp = fopen(template, "w");
|
||||
|
||||
if (fptmp == NULL)
|
||||
|
@ -1093,5 +1092,27 @@ HAMLIB_EXPORT(int) rig_settings_load(char *setting, void *value,
|
|||
return -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
HAMLIB_EXPORT(int) rig_settings_load_all(char * settings_file)
|
||||
{
|
||||
FILE *fp = fopen(settings_file, "r");
|
||||
char buf[4096];
|
||||
if (fp == NULL)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: settings_file error(%s): %s\n", __func__, settings_file, strerror(errno));
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
while(fgets(buf,sizeof(buf),fp))
|
||||
{
|
||||
char *s = strtok(buf,"=");
|
||||
char *v = strtok(NULL, "\r\n");
|
||||
if (strcmp(s,"sharedkey")==0)
|
||||
{
|
||||
//sharedkey = strdup(v);
|
||||
//rig_debug(RIG_DEBUG_TRACE, "%s: settings_file=%s, shared_key=%s\n", __func__, settings_file, sharedkey);
|
||||
}
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*! @} */
|
||||
|
|
|
@ -305,7 +305,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
case 'A':
|
||||
strncpy(rigctld_password, optarg, sizeof(rigctld_password) - 1);
|
||||
char *md5 = rig_make_md5(rigctld_password);
|
||||
//char *md5 = rig_make_m d5(rigctld_password);
|
||||
char md5[HAMLIB_SECRET_LENGTH+1];
|
||||
rig_password_generate_secret(rigctld_password, md5);
|
||||
printf("Secret key: %s\n", md5);
|
||||
rig_settings_save("sharedkey", md5, e_CHAR);
|
||||
break;
|
||||
|
@ -630,6 +632,7 @@ int main(int argc, char *argv[])
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "rigctld %s\n", hamlib_version2);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s",
|
||||
"Report bugs to <hamlib-developer@lists.sourceforge.net>\n\n");
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "Max# of rigctld client services=%d\n", NI_MAXSERV);
|
||||
|
||||
my_rig = rig_init(my_model);
|
||||
|
||||
|
@ -1221,7 +1224,7 @@ void *handle_socket(void *arg)
|
|||
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(-retcode))
|
||||
{
|
||||
int retry = 3;
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__)
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__);
|
||||
|
||||
do
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue