$ git clone https://socialnetwork.ion.nu/socialnetwork.git
commit 28231c5dad5362e98cee0f67102bee94b27bf70b
Author: Alicia <...>
Date: Mon Jan 23 20:44:18 2017 +0100
Fixed a path that still didn't use the path prefix.
diff --git a/social.c b/social.c
index 1715a1d..c8972af 100644
--- a/social.c
+++ b/social.c
@@ -28,7 +28,7 @@
struct user** social_users=0;
unsigned int social_usercount=0;
struct user* social_self;
-static char* prefix=0;
+char* social_prefix=0;
// Abstract away all the messagepassing and present information more or less statically
// TODO: Think about privacy for all data updates
// TODO: We must also sign all data updates to prevent forgeries
@@ -47,10 +47,10 @@ static void user_save(struct user* user)
{
if(!user->pubkey){return;}
// TODO: Absolute path, something like $HOME/.socialnetwork
- char path[strlen(prefix)+strlen("/users/0")+40];
- sprintf(path, "%s/users", prefix);
+ char path[strlen(social_prefix)+strlen("/users/0")+40];
+ sprintf(path, "%s/users", social_prefix);
mkdir(path, 0700);
- sprintf(path, "%s/users/"PEERFMT, prefix, PEERARG(user->id));
+ sprintf(path, "%s/users/"PEERFMT, social_prefix, PEERARG(user->id));
int f=open(path, O_WRONLY|O_CREAT|O_TRUNC, 0600);
gnutls_datum_t key;
gnutls_pubkey_export2(user->pubkey, GNUTLS_X509_FMT_PEM, &key);
@@ -67,8 +67,8 @@ static void user_load(struct user* user)
// Load user data (only pubkey atm), but spare pubkey if it's already set
if(!user->pubkey)
{
- char path[strlen(prefix)+strlen("/users/0")+40];
- sprintf(path, "%s/users/"PEERFMT, prefix, PEERARG(user->id));
+ char path[strlen(social_prefix)+strlen("/users/0")+40];
+ sprintf(path, "%s/users/"PEERFMT, social_prefix, PEERARG(user->id));
int f=open(path, O_RDONLY);
if(f>=0)
{
@@ -83,8 +83,8 @@ static void user_load(struct user* user)
}
}
// Load updates
- char path[strlen(prefix)+strlen("/updates/0")+40];
- sprintf(path, "%s/updates/"PEERFMT, prefix, PEERARG(user->id));
+ char path[strlen(social_prefix)+strlen("/updates/0")+40];
+ sprintf(path, "%s/updates/"PEERFMT, social_prefix, PEERARG(user->id));
int f=open(path, O_RDONLY);
if(f<0){return;}
uint64_t size;
@@ -180,8 +180,8 @@ static void sendupdates(struct peer* peer, void* data, unsigned int len)
void social_init(const char* keypath, const char* pathprefix)
{
- free(prefix);
- prefix=strdup(pathprefix);
+ free(social_prefix);
+ social_prefix=strdup(pathprefix);
// Load key, friends, circles, etc. our own profile
peer_init(keypath);
social_self=user_new(peer_id);
diff --git a/social.h b/social.h
index 0153288..e359b87 100644
--- a/social.h
+++ b/social.h
@@ -57,6 +57,7 @@ struct user
extern struct user** social_users;
extern unsigned int social_usercount;
extern struct user* social_self; // Most things we need to keep track of for ourself are the same things we need to keep track of for others
+extern char* social_prefix;
extern void social_init(const char* keypath, const char* pathprefix);
extern struct friendslist* social_user_getcircle(struct user* user, uint32_t circle);
extern void social_user_addtocircle(struct user* user, uint32_t circle, const unsigned char id[20]);
diff --git a/update.c b/update.c
index 5b63b5f..0aa5712 100644
--- a/update.c
+++ b/update.c
@@ -109,9 +109,8 @@ void social_update_sign(struct update* update)
void social_update_save(struct user* user, struct update* update)
{
- // TODO: Absolute path, something like $HOME/.socialnetwork
- char path[strlen("updates/0")+40];
- sprintf(path, "updates/"PEERFMT, PEERARG(user->id));
+ char path[strlen(social_prefix)+strlen("/updates/0")+40];
+ sprintf(path, "%s/updates/"PEERFMT, social_prefix, PEERARG(user->id));
mkdirp(path);
int f=open(path, O_WRONLY|O_CREAT|O_APPEND, 0600);
struct buffer buf;