Finish rename Marshall -> Marshal.
This commit is contained in:
parent
e818713484
commit
34540f0844
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "mpw-marshall-util.h"
|
#include "mpw-marshal-util.h"
|
||||||
#include "mpw-util.h"
|
#include "mpw-util.h"
|
||||||
|
|
||||||
char *mpw_get_token(const char **in, const char *eol, char *delim) {
|
char *mpw_get_token(const char **in, const char *eol, char *delim) {
|
@ -16,8 +16,8 @@
|
|||||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef _MPW_MARSHALL_UTIL_H
|
#ifndef _MPW_MARSHAL_UTIL_H
|
||||||
#define _MPW_MARSHALL_UTIL_H
|
#define _MPW_MARSHAL_UTIL_H
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if MPW_JSON
|
#if MPW_JSON
|
||||||
@ -70,4 +70,4 @@ bool mpw_update_masterKey(
|
|||||||
MPMasterKey *masterKey, MPAlgorithmVersion *masterKeyAlgorithm, MPAlgorithmVersion targetKeyAlgorithm,
|
MPMasterKey *masterKey, MPAlgorithmVersion *masterKeyAlgorithm, MPAlgorithmVersion targetKeyAlgorithm,
|
||||||
const char *fullName, const char *masterPassword);
|
const char *fullName, const char *masterPassword);
|
||||||
|
|
||||||
#endif // _MPW_MARSHALL_UTIL_H
|
#endif // _MPW_MARSHAL_UTIL_H
|
@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
#include "mpw-marshal.h"
|
#include "mpw-marshal.h"
|
||||||
#include "mpw-util.h"
|
#include "mpw-util.h"
|
||||||
#include "mpw-marshall-util.h"
|
#include "mpw-marshal-util.h"
|
||||||
|
|
||||||
MPMarshalledUser *mpw_marshall_user(
|
MPMarshalledUser *mpw_marshal_user(
|
||||||
const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion) {
|
const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion) {
|
||||||
|
|
||||||
MPMarshalledUser *user;
|
MPMarshalledUser *user;
|
||||||
@ -48,7 +48,7 @@ MPMarshalledUser *mpw_marshall_user(
|
|||||||
return user;
|
return user;
|
||||||
};
|
};
|
||||||
|
|
||||||
MPMarshalledSite *mpw_marshall_site(
|
MPMarshalledSite *mpw_marshal_site(
|
||||||
MPMarshalledUser *user, const char *siteName, const MPResultType resultType,
|
MPMarshalledUser *user, const char *siteName, const MPResultType resultType,
|
||||||
const MPCounterValue siteCounter, const MPAlgorithmVersion algorithmVersion) {
|
const MPCounterValue siteCounter, const MPAlgorithmVersion algorithmVersion) {
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ bool mpw_marshal_free(
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mpw_marshall_write_flat(
|
static bool mpw_marshal_write_flat(
|
||||||
char **out, const MPMarshalledUser *user, MPMarshalError *error) {
|
char **out, const MPMarshalledUser *user, MPMarshalError *error) {
|
||||||
|
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
||||||
@ -216,7 +216,7 @@ static bool mpw_marshall_write_flat(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MPW_JSON
|
#if MPW_JSON
|
||||||
static bool mpw_marshall_write_json(
|
static bool mpw_marshal_write_json(
|
||||||
char **out, const MPMarshalledUser *user, MPMarshalError *error) {
|
char **out, const MPMarshalledUser *user, MPMarshalError *error) {
|
||||||
|
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
||||||
@ -345,7 +345,7 @@ static bool mpw_marshall_write_json(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool mpw_marshall_write(
|
bool mpw_marshal_write(
|
||||||
char **out, const MPMarshalFormat outFormat, const MPMarshalledUser *user, MPMarshalError *error) {
|
char **out, const MPMarshalFormat outFormat, const MPMarshalledUser *user, MPMarshalError *error) {
|
||||||
|
|
||||||
switch (outFormat) {
|
switch (outFormat) {
|
||||||
@ -353,10 +353,10 @@ bool mpw_marshall_write(
|
|||||||
*error = (MPMarshalError){ .type = MPMarshalSuccess };
|
*error = (MPMarshalError){ .type = MPMarshalSuccess };
|
||||||
return false;
|
return false;
|
||||||
case MPMarshalFormatFlat:
|
case MPMarshalFormatFlat:
|
||||||
return mpw_marshall_write_flat( out, user, error );
|
return mpw_marshal_write_flat( out, user, error );
|
||||||
#if MPW_JSON
|
#if MPW_JSON
|
||||||
case MPMarshalFormatJSON:
|
case MPMarshalFormatJSON:
|
||||||
return mpw_marshall_write_json( out, user, error );
|
return mpw_marshal_write_json( out, user, error );
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
*error = (MPMarshalError){ MPMarshalErrorFormat, mpw_str( "Unsupported output format: %u", outFormat ) };
|
*error = (MPMarshalError){ MPMarshalErrorFormat, mpw_str( "Unsupported output format: %u", outFormat ) };
|
||||||
@ -364,7 +364,7 @@ bool mpw_marshall_write(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mpw_marshall_read_flat_info(
|
static void mpw_marshal_read_flat_info(
|
||||||
const char *in, MPMarshalInfo *info) {
|
const char *in, MPMarshalInfo *info) {
|
||||||
|
|
||||||
info->algorithm = MPAlgorithmVersionCurrent;
|
info->algorithm = MPAlgorithmVersionCurrent;
|
||||||
@ -411,7 +411,7 @@ static void mpw_marshall_read_flat_info(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static MPMarshalledUser *mpw_marshall_read_flat(
|
static MPMarshalledUser *mpw_marshal_read_flat(
|
||||||
const char *in, const char *masterPassword, MPMarshalError *error) {
|
const char *in, const char *masterPassword, MPMarshalError *error) {
|
||||||
|
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
||||||
@ -508,7 +508,7 @@ static MPMarshalledUser *mpw_marshall_read_flat(
|
|||||||
*error = (MPMarshalError){ MPMarshalErrorMasterPassword, "Master password doesn't match key ID." };
|
*error = (MPMarshalError){ MPMarshalErrorMasterPassword, "Master password doesn't match key ID." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!(user = mpw_marshall_user( fullName, masterPassword, algorithm ))) {
|
if (!(user = mpw_marshal_user( fullName, masterPassword, algorithm ))) {
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new user." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new user." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -582,7 +582,7 @@ static MPMarshalledUser *mpw_marshall_read_flat(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPMarshalledSite *site = mpw_marshall_site(
|
MPMarshalledSite *site = mpw_marshal_site(
|
||||||
user, siteName, siteType, siteCounter, siteAlgorithm );
|
user, siteName, siteType, siteCounter, siteAlgorithm );
|
||||||
if (!site) {
|
if (!site) {
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new site." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new site." };
|
||||||
@ -632,7 +632,7 @@ static MPMarshalledUser *mpw_marshall_read_flat(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MPW_JSON
|
#if MPW_JSON
|
||||||
static void mpw_marshall_read_json_info(
|
static void mpw_marshal_read_json_info(
|
||||||
const char *in, MPMarshalInfo *info) {
|
const char *in, MPMarshalInfo *info) {
|
||||||
|
|
||||||
// Parse JSON.
|
// Parse JSON.
|
||||||
@ -656,7 +656,7 @@ static void mpw_marshall_read_json_info(
|
|||||||
json_object_put( json_file );
|
json_object_put( json_file );
|
||||||
}
|
}
|
||||||
|
|
||||||
static MPMarshalledUser *mpw_marshall_read_json(
|
static MPMarshalledUser *mpw_marshal_read_json(
|
||||||
const char *in, const char *masterPassword, MPMarshalError *error) {
|
const char *in, const char *masterPassword, MPMarshalError *error) {
|
||||||
|
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Unexpected internal error." };
|
||||||
@ -720,7 +720,7 @@ static MPMarshalledUser *mpw_marshall_read_json(
|
|||||||
*error = (MPMarshalError){ MPMarshalErrorMasterPassword, "Master password doesn't match key ID." };
|
*error = (MPMarshalError){ MPMarshalErrorMasterPassword, "Master password doesn't match key ID." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!(user = mpw_marshall_user( fullName, masterPassword, algorithm ))) {
|
if (!(user = mpw_marshal_user( fullName, masterPassword, algorithm ))) {
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new user." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new user." };
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -765,7 +765,7 @@ static MPMarshalledUser *mpw_marshall_read_json(
|
|||||||
json_object *json_site_mpw = mpw_get_json_section( json_site.val, "_ext_mpw" );
|
json_object *json_site_mpw = mpw_get_json_section( json_site.val, "_ext_mpw" );
|
||||||
const char *siteURL = mpw_get_json_string( json_site_mpw, "url", NULL );
|
const char *siteURL = mpw_get_json_string( json_site_mpw, "url", NULL );
|
||||||
|
|
||||||
MPMarshalledSite *site = mpw_marshall_site( user, siteName, siteType, siteCounter, siteAlgorithm );
|
MPMarshalledSite *site = mpw_marshal_site( user, siteName, siteType, siteCounter, siteAlgorithm );
|
||||||
if (!site) {
|
if (!site) {
|
||||||
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new site." };
|
*error = (MPMarshalError){ MPMarshalErrorInternal, "Couldn't allocate a new site." };
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -824,7 +824,7 @@ static MPMarshalledUser *mpw_marshall_read_json(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MPMarshalInfo *mpw_marshall_read_info(
|
MPMarshalInfo *mpw_marshal_read_info(
|
||||||
const char *in) {
|
const char *in) {
|
||||||
|
|
||||||
MPMarshalInfo *info = malloc( sizeof( MPMarshalInfo ) );
|
MPMarshalInfo *info = malloc( sizeof( MPMarshalInfo ) );
|
||||||
@ -833,12 +833,12 @@ MPMarshalInfo *mpw_marshall_read_info(
|
|||||||
if (in && strlen( in )) {
|
if (in && strlen( in )) {
|
||||||
if (in[0] == '#') {
|
if (in[0] == '#') {
|
||||||
*info = (MPMarshalInfo){ .format = MPMarshalFormatFlat };
|
*info = (MPMarshalInfo){ .format = MPMarshalFormatFlat };
|
||||||
mpw_marshall_read_flat_info( in, info );
|
mpw_marshal_read_flat_info( in, info );
|
||||||
}
|
}
|
||||||
else if (in[0] == '{') {
|
else if (in[0] == '{') {
|
||||||
*info = (MPMarshalInfo){ .format = MPMarshalFormatJSON };
|
*info = (MPMarshalInfo){ .format = MPMarshalFormatJSON };
|
||||||
#if MPW_JSON
|
#if MPW_JSON
|
||||||
mpw_marshall_read_json_info( in, info );
|
mpw_marshal_read_json_info( in, info );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -846,7 +846,7 @@ MPMarshalInfo *mpw_marshall_read_info(
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPMarshalledUser *mpw_marshall_read(
|
MPMarshalledUser *mpw_marshal_read(
|
||||||
const char *in, const MPMarshalFormat inFormat, const char *masterPassword, MPMarshalError *error) {
|
const char *in, const MPMarshalFormat inFormat, const char *masterPassword, MPMarshalError *error) {
|
||||||
|
|
||||||
switch (inFormat) {
|
switch (inFormat) {
|
||||||
@ -854,10 +854,10 @@ MPMarshalledUser *mpw_marshall_read(
|
|||||||
*error = (MPMarshalError){ .type = MPMarshalSuccess };
|
*error = (MPMarshalError){ .type = MPMarshalSuccess };
|
||||||
return false;
|
return false;
|
||||||
case MPMarshalFormatFlat:
|
case MPMarshalFormatFlat:
|
||||||
return mpw_marshall_read_flat( in, masterPassword, error );
|
return mpw_marshal_read_flat( in, masterPassword, error );
|
||||||
#if MPW_JSON
|
#if MPW_JSON
|
||||||
case MPMarshalFormatJSON:
|
case MPMarshalFormatJSON:
|
||||||
return mpw_marshall_read_json( in, masterPassword, error );
|
return mpw_marshal_read_json( in, masterPassword, error );
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
*error = (MPMarshalError){ MPMarshalErrorFormat, mpw_str( "Unsupported input format: %u", inFormat ) };
|
*error = (MPMarshalError){ MPMarshalErrorFormat, mpw_str( "Unsupported input format: %u", inFormat ) };
|
||||||
@ -906,7 +906,7 @@ const char *mpw_nameForFormat(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *mpw_marshall_format_extension(
|
const char *mpw_marshal_format_extension(
|
||||||
const MPMarshalFormat format) {
|
const MPMarshalFormat format) {
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef _MPW_MARSHALL_H
|
#ifndef _MPW_MARSHAL_H
|
||||||
#define _MPW_MARSHALL_H
|
#define _MPW_MARSHAL_H
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@ -111,22 +111,22 @@ typedef struct MPMarshalInfo {
|
|||||||
//// Marshalling.
|
//// Marshalling.
|
||||||
|
|
||||||
/** Write the user and all associated data out to the given output buffer using the given marshalling format. */
|
/** Write the user and all associated data out to the given output buffer using the given marshalling format. */
|
||||||
bool mpw_marshall_write(
|
bool mpw_marshal_write(
|
||||||
char **out, const MPMarshalFormat outFormat, const MPMarshalledUser *user, MPMarshalError *error);
|
char **out, const MPMarshalFormat outFormat, const MPMarshalledUser *user, MPMarshalError *error);
|
||||||
/** Try to read metadata on the sites in the input buffer. */
|
/** Try to read metadata on the sites in the input buffer. */
|
||||||
MPMarshalInfo *mpw_marshall_read_info(
|
MPMarshalInfo *mpw_marshal_read_info(
|
||||||
const char *in);
|
const char *in);
|
||||||
/** Unmarshall sites in the given input buffer by parsing it using the given marshalling format. */
|
/** Unmarshall sites in the given input buffer by parsing it using the given marshalling format. */
|
||||||
MPMarshalledUser *mpw_marshall_read(
|
MPMarshalledUser *mpw_marshal_read(
|
||||||
const char *in, const MPMarshalFormat inFormat, const char *masterPassword, MPMarshalError *error);
|
const char *in, const MPMarshalFormat inFormat, const char *masterPassword, MPMarshalError *error);
|
||||||
|
|
||||||
//// Utilities.
|
//// Utilities.
|
||||||
|
|
||||||
/** Create a new user object ready for marshalling. */
|
/** Create a new user object ready for marshalling. */
|
||||||
MPMarshalledUser *mpw_marshall_user(
|
MPMarshalledUser *mpw_marshal_user(
|
||||||
const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion);
|
const char *fullName, const char *masterPassword, const MPAlgorithmVersion algorithmVersion);
|
||||||
/** Create a new site attached to the given user object, ready for marshalling. */
|
/** Create a new site attached to the given user object, ready for marshalling. */
|
||||||
MPMarshalledSite *mpw_marshall_site(
|
MPMarshalledSite *mpw_marshal_site(
|
||||||
MPMarshalledUser *user,
|
MPMarshalledUser *user,
|
||||||
const char *siteName, const MPResultType resultType, const MPCounterValue siteCounter, const MPAlgorithmVersion algorithmVersion);
|
const char *siteName, const MPResultType resultType, const MPCounterValue siteCounter, const MPAlgorithmVersion algorithmVersion);
|
||||||
/** Create a new question attached to the given site object, ready for marshalling. */
|
/** Create a new question attached to the given site object, ready for marshalling. */
|
||||||
@ -153,7 +153,7 @@ const char *mpw_nameForFormat(
|
|||||||
/**
|
/**
|
||||||
* @return The file extension that's recommended for files that use the given marshalling format.
|
* @return The file extension that's recommended for files that use the given marshalling format.
|
||||||
*/
|
*/
|
||||||
const char *mpw_marshall_format_extension(
|
const char *mpw_marshal_format_extension(
|
||||||
const MPMarshalFormat format);
|
const MPMarshalFormat format);
|
||||||
|
|
||||||
#endif // _MPW_MARSHALL_H
|
#endif // _MPW_MARSHAL_H
|
||||||
|
@ -253,7 +253,7 @@
|
|||||||
DAADBFE01A68763B00F7A756 /* mpw-algorithm.c in Sources */ = {isa = PBXBuildFile; fileRef = 93D3969393A3A46BD27D7078 /* mpw-algorithm.c */; };
|
DAADBFE01A68763B00F7A756 /* mpw-algorithm.c in Sources */ = {isa = PBXBuildFile; fileRef = 93D3969393A3A46BD27D7078 /* mpw-algorithm.c */; };
|
||||||
DAB7AE5D1F3D752900C856B1 /* libjson-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB7AE5C1F3D752900C856B1 /* libjson-c.a */; };
|
DAB7AE5D1F3D752900C856B1 /* libjson-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB7AE5C1F3D752900C856B1 /* libjson-c.a */; };
|
||||||
DAB7AE771F3D755B00C856B1 /* libjson-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB7AE761F3D755B00C856B1 /* libjson-c.a */; };
|
DAB7AE771F3D755B00C856B1 /* libjson-c.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAB7AE761F3D755B00C856B1 /* libjson-c.a */; };
|
||||||
DAB7AE991F3DDEE000C856B1 /* mpw-marshall-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DAB7AE981F3DDEE000C856B1 /* mpw-marshall-util.c */; };
|
DAB7AE991F3DDEE000C856B1 /* mpw-marshal-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DAB7AE981F3DDEE000C856B1 /* mpw-marshal-util.c */; };
|
||||||
DABB981615100B4000B05417 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DABB981515100B4000B05417 /* SystemConfiguration.framework */; };
|
DABB981615100B4000B05417 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DABB981515100B4000B05417 /* SystemConfiguration.framework */; };
|
||||||
DABD39371711E29700CF925C /* avatar-0.png in Resources */ = {isa = PBXBuildFile; fileRef = DABD366C1711E29400CF925C /* avatar-0.png */; };
|
DABD39371711E29700CF925C /* avatar-0.png in Resources */ = {isa = PBXBuildFile; fileRef = DABD366C1711E29400CF925C /* avatar-0.png */; };
|
||||||
DABD39381711E29700CF925C /* avatar-0@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DABD366D1711E29400CF925C /* avatar-0@2x.png */; };
|
DABD39381711E29700CF925C /* avatar-0@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DABD366D1711E29400CF925C /* avatar-0@2x.png */; };
|
||||||
@ -896,8 +896,8 @@
|
|||||||
DAB7AE731F3D755B00C856B1 /* strdup_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strdup_compat.h; sourceTree = "<group>"; };
|
DAB7AE731F3D755B00C856B1 /* strdup_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strdup_compat.h; sourceTree = "<group>"; };
|
||||||
DAB7AE741F3D755B00C856B1 /* vasprintf_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vasprintf_compat.h; sourceTree = "<group>"; };
|
DAB7AE741F3D755B00C856B1 /* vasprintf_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vasprintf_compat.h; sourceTree = "<group>"; };
|
||||||
DAB7AE761F3D755B00C856B1 /* libjson-c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libjson-c.a"; sourceTree = "<group>"; };
|
DAB7AE761F3D755B00C856B1 /* libjson-c.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libjson-c.a"; sourceTree = "<group>"; };
|
||||||
DAB7AE971F3DDEE000C856B1 /* mpw-marshall-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshall-util.h"; sourceTree = "<group>"; };
|
DAB7AE971F3DDEE000C856B1 /* mpw-marshal-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshal-util.h"; sourceTree = "<group>"; };
|
||||||
DAB7AE981F3DDEE000C856B1 /* mpw-marshall-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshall-util.c"; sourceTree = "<group>"; };
|
DAB7AE981F3DDEE000C856B1 /* mpw-marshal-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshal-util.c"; sourceTree = "<group>"; };
|
||||||
DABB981515100B4000B05417 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
DABB981515100B4000B05417 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||||
DABD360F1711E29400CF925C /* ui_background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ui_background.png; sourceTree = "<group>"; };
|
DABD360F1711E29400CF925C /* ui_background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ui_background.png; sourceTree = "<group>"; };
|
||||||
DABD36101711E29400CF925C /* ui_background@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ui_background@2x.png"; sourceTree = "<group>"; };
|
DABD36101711E29400CF925C /* ui_background@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ui_background@2x.png"; sourceTree = "<group>"; };
|
||||||
@ -1759,8 +1759,8 @@
|
|||||||
93D39D4E713564B7654341B0 /* mpw-algorithm_v3.c */,
|
93D39D4E713564B7654341B0 /* mpw-algorithm_v3.c */,
|
||||||
93D3969393A3A46BD27D7078 /* mpw-algorithm.c */,
|
93D3969393A3A46BD27D7078 /* mpw-algorithm.c */,
|
||||||
93D3990D850D76A94C6B7A4D /* mpw-algorithm.h */,
|
93D3990D850D76A94C6B7A4D /* mpw-algorithm.h */,
|
||||||
DAB7AE981F3DDEE000C856B1 /* mpw-marshall-util.c */,
|
DAB7AE981F3DDEE000C856B1 /* mpw-marshal-util.c */,
|
||||||
DAB7AE971F3DDEE000C856B1 /* mpw-marshall-util.h */,
|
DAB7AE971F3DDEE000C856B1 /* mpw-marshal-util.h */,
|
||||||
DAA449D01EEC4B5800E7BDD5 /* mpw-marshal.c */,
|
DAA449D01EEC4B5800E7BDD5 /* mpw-marshal.c */,
|
||||||
DAA449D11EEC4B5800E7BDD5 /* mpw-marshal.h */,
|
DAA449D11EEC4B5800E7BDD5 /* mpw-marshal.h */,
|
||||||
93D392C5A6572DB0EB5B82C8 /* mpw-types.c */,
|
93D392C5A6572DB0EB5B82C8 /* mpw-types.c */,
|
||||||
@ -3988,7 +3988,7 @@
|
|||||||
DA0CC58E1EB6B030009A8ED9 /* MPSiteQuestionEntity+CoreDataClass.m in Sources */,
|
DA0CC58E1EB6B030009A8ED9 /* MPSiteQuestionEntity+CoreDataClass.m in Sources */,
|
||||||
93D39A5FF670957C0AF8298D /* MPSiteCell.m in Sources */,
|
93D39A5FF670957C0AF8298D /* MPSiteCell.m in Sources */,
|
||||||
93D398ECD7D1A0DEDDADF516 /* MPEmergencyViewController.m in Sources */,
|
93D398ECD7D1A0DEDDADF516 /* MPEmergencyViewController.m in Sources */,
|
||||||
DAB7AE991F3DDEE000C856B1 /* mpw-marshall-util.c in Sources */,
|
DAB7AE991F3DDEE000C856B1 /* mpw-marshal-util.c in Sources */,
|
||||||
DA95B50F1C4776F00067F5EF /* NSMutableSet+Pearl.m in Sources */,
|
DA95B50F1C4776F00067F5EF /* NSMutableSet+Pearl.m in Sources */,
|
||||||
93D394B5036C882B33C71872 /* MPSitesSegue.m in Sources */,
|
93D394B5036C882B33C71872 /* MPSitesSegue.m in Sources */,
|
||||||
DA0CC5911EB6B030009A8ED9 /* MPStoredSiteEntity+CoreDataProperties.m in Sources */,
|
DA0CC5911EB6B030009A8ED9 /* MPStoredSiteEntity+CoreDataProperties.m in Sources */,
|
||||||
|
@ -110,8 +110,8 @@
|
|||||||
DA6774431A474A3B004F356A /* mpw-algorithm.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773BB1A4746AF004F356A /* mpw-algorithm.c */; };
|
DA6774431A474A3B004F356A /* mpw-algorithm.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773BB1A4746AF004F356A /* mpw-algorithm.c */; };
|
||||||
DA6774451A474A3B004F356A /* mpw-types.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773C21A4746AF004F356A /* mpw-types.c */; };
|
DA6774451A474A3B004F356A /* mpw-types.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773C21A4746AF004F356A /* mpw-types.c */; };
|
||||||
DA6774461A474A3B004F356A /* mpw-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773C51A4746AF004F356A /* mpw-util.c */; };
|
DA6774461A474A3B004F356A /* mpw-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA6773C51A4746AF004F356A /* mpw-util.c */; };
|
||||||
DA7471A31F2B71AE005F3468 /* mpw-marshall-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */; };
|
DA7471A31F2B71AE005F3468 /* mpw-marshal-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */; };
|
||||||
DA7471A61F2B71B9005F3468 /* mpw-marshall-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */; };
|
DA7471A61F2B71B9005F3468 /* mpw-marshal-util.c in Sources */ = {isa = PBXBuildFile; fileRef = DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */; };
|
||||||
DA89D4EC1A51EABD00AC64D7 /* Pearl-Cocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = DA89D4EA1A51EABD00AC64D7 /* Pearl-Cocoa.h */; };
|
DA89D4EC1A51EABD00AC64D7 /* Pearl-Cocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = DA89D4EA1A51EABD00AC64D7 /* Pearl-Cocoa.h */; };
|
||||||
DA89D4ED1A51EABD00AC64D7 /* Pearl-Cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = DA89D4EB1A51EABD00AC64D7 /* Pearl-Cocoa.m */; };
|
DA89D4ED1A51EABD00AC64D7 /* Pearl-Cocoa.m in Sources */ = {isa = PBXBuildFile; fileRef = DA89D4EB1A51EABD00AC64D7 /* Pearl-Cocoa.m */; };
|
||||||
DA8ED895192906920099B726 /* PearlTween.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8ED891192906920099B726 /* PearlTween.m */; };
|
DA8ED895192906920099B726 /* PearlTween.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8ED891192906920099B726 /* PearlTween.m */; };
|
||||||
@ -950,8 +950,8 @@
|
|||||||
DA6773C51A4746AF004F356A /* mpw-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-util.c"; sourceTree = "<group>"; };
|
DA6773C51A4746AF004F356A /* mpw-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-util.c"; sourceTree = "<group>"; };
|
||||||
DA6773C61A4746AF004F356A /* mpw-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-util.h"; sourceTree = "<group>"; };
|
DA6773C61A4746AF004F356A /* mpw-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-util.h"; sourceTree = "<group>"; };
|
||||||
DA67743B1A474A03004F356A /* mpw-test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "mpw-test"; sourceTree = BUILT_PRODUCTS_DIR; };
|
DA67743B1A474A03004F356A /* mpw-test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "mpw-test"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshall-util.c"; sourceTree = "<group>"; };
|
DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "mpw-marshal-util.c"; sourceTree = "<group>"; };
|
||||||
DA7471A11F2B71A9005F3468 /* mpw-marshall-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshall-util.h"; sourceTree = "<group>"; };
|
DA7471A11F2B71A9005F3468 /* mpw-marshal-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mpw-marshal-util.h"; sourceTree = "<group>"; };
|
||||||
DA771FE51E6E15A1004D7EDE /* MasterPassword-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MasterPassword-Prefix.pch"; sourceTree = "<group>"; };
|
DA771FE51E6E15A1004D7EDE /* MasterPassword-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MasterPassword-Prefix.pch"; sourceTree = "<group>"; };
|
||||||
DA831A271A6E1146000AC234 /* mpw-algorithm_v0.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "mpw-algorithm_v0.c"; sourceTree = "<group>"; };
|
DA831A271A6E1146000AC234 /* mpw-algorithm_v0.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "mpw-algorithm_v0.c"; sourceTree = "<group>"; };
|
||||||
DA831A281A6E1146000AC234 /* mpw-algorithm_v1.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "mpw-algorithm_v1.c"; sourceTree = "<group>"; };
|
DA831A281A6E1146000AC234 /* mpw-algorithm_v1.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "mpw-algorithm_v1.c"; sourceTree = "<group>"; };
|
||||||
@ -1887,8 +1887,8 @@
|
|||||||
DA831A2A1A6E1146000AC234 /* mpw-algorithm_v3.c */,
|
DA831A2A1A6E1146000AC234 /* mpw-algorithm_v3.c */,
|
||||||
DA6773BB1A4746AF004F356A /* mpw-algorithm.c */,
|
DA6773BB1A4746AF004F356A /* mpw-algorithm.c */,
|
||||||
DA6773BC1A4746AF004F356A /* mpw-algorithm.h */,
|
DA6773BC1A4746AF004F356A /* mpw-algorithm.h */,
|
||||||
DA7471A01F2B71A9005F3468 /* mpw-marshall-util.c */,
|
DA7471A01F2B71A9005F3468 /* mpw-marshal-util.c */,
|
||||||
DA7471A11F2B71A9005F3468 /* mpw-marshall-util.h */,
|
DA7471A11F2B71A9005F3468 /* mpw-marshal-util.h */,
|
||||||
DAA449D31EEC4B6B00E7BDD5 /* mpw-marshal.c */,
|
DAA449D31EEC4B6B00E7BDD5 /* mpw-marshal.c */,
|
||||||
DAA449D41EEC4B6B00E7BDD5 /* mpw-marshal.h */,
|
DAA449D41EEC4B6B00E7BDD5 /* mpw-marshal.h */,
|
||||||
DA6773C21A4746AF004F356A /* mpw-types.c */,
|
DA6773C21A4746AF004F356A /* mpw-types.c */,
|
||||||
@ -2676,7 +2676,7 @@
|
|||||||
DAAF16661F5CA3240013B8AE /* mpw-cli-util.c in Sources */,
|
DAAF16661F5CA3240013B8AE /* mpw-cli-util.c in Sources */,
|
||||||
DA1C7AAC1F1A8F24009A3551 /* mpw-util.c in Sources */,
|
DA1C7AAC1F1A8F24009A3551 /* mpw-util.c in Sources */,
|
||||||
DA1C7AC31F1A8FBA009A3551 /* mpw-cli.c in Sources */,
|
DA1C7AC31F1A8FBA009A3551 /* mpw-cli.c in Sources */,
|
||||||
DA7471A31F2B71AE005F3468 /* mpw-marshall-util.c in Sources */,
|
DA7471A31F2B71AE005F3468 /* mpw-marshal-util.c in Sources */,
|
||||||
DA1C7AAD1F1A8F24009A3551 /* mpw-algorithm.c in Sources */,
|
DA1C7AAD1F1A8F24009A3551 /* mpw-algorithm.c in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -2738,7 +2738,7 @@
|
|||||||
DA4DAE941A7D8117003E5423 /* MPAlgorithmV3.m in Sources */,
|
DA4DAE941A7D8117003E5423 /* MPAlgorithmV3.m in Sources */,
|
||||||
DA4DAE951A7D8117003E5423 /* MPTypes.m in Sources */,
|
DA4DAE951A7D8117003E5423 /* MPTypes.m in Sources */,
|
||||||
93D393A1646430FAAC73E7FE /* MPMacApplication.m in Sources */,
|
93D393A1646430FAAC73E7FE /* MPMacApplication.m in Sources */,
|
||||||
DA7471A61F2B71B9005F3468 /* mpw-marshall-util.c in Sources */,
|
DA7471A61F2B71B9005F3468 /* mpw-marshal-util.c in Sources */,
|
||||||
93D398D1F5D8CD5A22AF6929 /* MPGradientView.m in Sources */,
|
93D398D1F5D8CD5A22AF6929 /* MPGradientView.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -566,7 +566,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
|||||||
saveInContext:(NSManagedObjectContext *)context {
|
saveInContext:(NSManagedObjectContext *)context {
|
||||||
|
|
||||||
// Read metadata for the import file.
|
// Read metadata for the import file.
|
||||||
MPMarshalInfo *info = mpw_marshall_read_info( importData.UTF8String );
|
MPMarshalInfo *info = mpw_marshal_read_info( importData.UTF8String );
|
||||||
if (info->format == MPMarshalFormatNone)
|
if (info->format == MPMarshalFormatNone)
|
||||||
return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{
|
return MPError( ([NSError errorWithDomain:MPErrorDomain code:MPErrorMarshalCode userInfo:@{
|
||||||
@"type" : @(MPMarshalErrorFormat),
|
@"type" : @(MPMarshalErrorFormat),
|
||||||
@ -590,7 +590,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
|||||||
|
|
||||||
// Parse import data.
|
// Parse import data.
|
||||||
MPMarshalError importError = { .type = MPMarshalSuccess };
|
MPMarshalError importError = { .type = MPMarshalSuccess };
|
||||||
MPMarshalledUser *importUser = mpw_marshall_read( importData.UTF8String, info->format, importMasterPassword.UTF8String, &importError );
|
MPMarshalledUser *importUser = mpw_marshal_read( importData.UTF8String, info->format, importMasterPassword.UTF8String, &importError );
|
||||||
mpw_marshal_info_free( &info );
|
mpw_marshal_info_free( &info );
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
@ -707,7 +707,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
|||||||
NSString *masterPassword = askImportPassword( user.name );
|
NSString *masterPassword = askImportPassword( user.name );
|
||||||
|
|
||||||
inf( @"Exporting sites, %@, for user: %@", revealPasswords? @"revealing passwords": @"omitting passwords", user.userID );
|
inf( @"Exporting sites, %@, for user: %@", revealPasswords? @"revealing passwords": @"omitting passwords", user.userID );
|
||||||
MPMarshalledUser *exportUser = mpw_marshall_user( user.name.UTF8String, masterPassword.UTF8String, user.algorithm.version );
|
MPMarshalledUser *exportUser = mpw_marshal_user( user.name.UTF8String, masterPassword.UTF8String, user.algorithm.version );
|
||||||
exportUser->redacted = !revealPasswords;
|
exportUser->redacted = !revealPasswords;
|
||||||
exportUser->avatar = (unsigned int)user.avatar;
|
exportUser->avatar = (unsigned int)user.avatar;
|
||||||
exportUser->defaultType = user.defaultType;
|
exportUser->defaultType = user.defaultType;
|
||||||
@ -721,7 +721,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
|||||||
? [site.algorithm exportPasswordForSite:site usingKey:self.key]
|
? [site.algorithm exportPasswordForSite:site usingKey:self.key]
|
||||||
: [site.algorithm resolvePasswordForSite:site usingKey:self.key];
|
: [site.algorithm resolvePasswordForSite:site usingKey:self.key];
|
||||||
|
|
||||||
MPMarshalledSite *exportSite = mpw_marshall_site( exportUser,
|
MPMarshalledSite *exportSite = mpw_marshal_site( exportUser,
|
||||||
site.name.UTF8String, site.type, counter, site.algorithm.version );
|
site.name.UTF8String, site.type, counter, site.algorithm.version );
|
||||||
exportSite->content = content.UTF8String;
|
exportSite->content = content.UTF8String;
|
||||||
exportSite->loginContent = site.loginName.UTF8String;
|
exportSite->loginContent = site.loginName.UTF8String;
|
||||||
@ -736,7 +736,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
|||||||
|
|
||||||
char *export = NULL;
|
char *export = NULL;
|
||||||
MPMarshalError exportError = (MPMarshalError){ .type= MPMarshalSuccess };
|
MPMarshalError exportError = (MPMarshalError){ .type= MPMarshalSuccess };
|
||||||
mpw_marshall_write( &export, MPMarshalFormatFlat, exportUser, &exportError );
|
mpw_marshal_write( &export, MPMarshalFormatFlat, exportUser, &exportError );
|
||||||
NSString *mpsites = nil;
|
NSString *mpsites = nil;
|
||||||
if (export && exportError.type == MPMarshalSuccess)
|
if (export && exportError.type == MPMarshalSuccess)
|
||||||
mpsites = [NSString stringWithCString:export encoding:NSUTF8StringEncoding];
|
mpsites = [NSString stringWithCString:export encoding:NSUTF8StringEncoding];
|
||||||
|
@ -236,7 +236,7 @@
|
|||||||
|
|
||||||
PearlNotMainQueue( ^{
|
PearlNotMainQueue( ^{
|
||||||
NSString *importData = [UIPasteboard generalPasteboard].string;
|
NSString *importData = [UIPasteboard generalPasteboard].string;
|
||||||
MPMarshalInfo *importInfo = mpw_marshall_read_info( importData.UTF8String );
|
MPMarshalInfo *importInfo = mpw_marshal_read_info( importData.UTF8String );
|
||||||
if (importInfo->format != MPMarshalFormatNone)
|
if (importInfo->format != MPMarshalFormatNone)
|
||||||
[PearlAlert showAlertWithTitle:@"Import Sites?" message:
|
[PearlAlert showAlertWithTitle:@"Import Sites?" message:
|
||||||
@"We've detected Master Password import sites on your pasteboard, would you like to import them?"
|
@"We've detected Master Password import sites on your pasteboard, would you like to import them?"
|
||||||
|
@ -99,7 +99,7 @@ endfunction()
|
|||||||
### TARGET: MPW
|
### TARGET: MPW
|
||||||
if( BUILD_MPW )
|
if( BUILD_MPW )
|
||||||
# target
|
# target
|
||||||
add_executable( mpw "core/base64.c" "core/mpw-algorithm.c" "core/mpw-types.c" "core/mpw-util.c" "core/mpw-marshall-util.c" "core/mpw-marshall.c"
|
add_executable( mpw "core/base64.c" "core/mpw-algorithm.c" "core/mpw-types.c" "core/mpw-util.c" "core/mpw-marshal-util.c" "core/mpw-marshal.c"
|
||||||
"cli/mpw-cli-util.c" "cli/mpw-cli.c" )
|
"cli/mpw-cli-util.c" "cli/mpw-cli.c" )
|
||||||
target_include_directories( mpw PUBLIC core cli )
|
target_include_directories( mpw PUBLIC core cli )
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ static void usage() {
|
|||||||
" n, none | No file\n"
|
" n, none | No file\n"
|
||||||
" f, flat | ~/.mpw.d/Full Name.%s\n"
|
" f, flat | ~/.mpw.d/Full Name.%s\n"
|
||||||
" j, json | ~/.mpw.d/Full Name.%s\n\n",
|
" j, json | ~/.mpw.d/Full Name.%s\n\n",
|
||||||
MP_ENV_format, mpw_marshall_format_extension( MPMarshalFormatFlat ), mpw_marshall_format_extension( MPMarshalFormatJSON ) );
|
MP_ENV_format, mpw_marshal_format_extension( MPMarshalFormatFlat ), mpw_marshal_format_extension( MPMarshalFormatJSON ) );
|
||||||
inf( ""
|
inf( ""
|
||||||
" -R redacted Whether to save the mpsites in redacted format or not.\n"
|
" -R redacted Whether to save the mpsites in redacted format or not.\n"
|
||||||
" Redaction omits or encrypts any secrets, making the file safe\n"
|
" Redaction omits or encrypts any secrets, making the file safe\n"
|
||||||
@ -446,14 +446,14 @@ void cli_user(Arguments *args, Operation *operation) {
|
|||||||
// Find mpsites file from parameters.
|
// Find mpsites file from parameters.
|
||||||
FILE *sitesFile = NULL;
|
FILE *sitesFile = NULL;
|
||||||
mpw_free_string( &operation->sitesPath );
|
mpw_free_string( &operation->sitesPath );
|
||||||
operation->sitesPath = mpw_path( operation->fullName, mpw_marshall_format_extension( operation->sitesFormat ) );
|
operation->sitesPath = mpw_path( operation->fullName, mpw_marshal_format_extension( operation->sitesFormat ) );
|
||||||
if (!operation->sitesPath || !(sitesFile = fopen( operation->sitesPath, "r" ))) {
|
if (!operation->sitesPath || !(sitesFile = fopen( operation->sitesPath, "r" ))) {
|
||||||
dbg( "Couldn't open configuration file:\n %s: %s\n", operation->sitesPath, strerror( errno ) );
|
dbg( "Couldn't open configuration file:\n %s: %s\n", operation->sitesPath, strerror( errno ) );
|
||||||
|
|
||||||
// Try to fall back to the flat format.
|
// Try to fall back to the flat format.
|
||||||
if (!operation->sitesFormatFixed) {
|
if (!operation->sitesFormatFixed) {
|
||||||
mpw_free_string( &operation->sitesPath );
|
mpw_free_string( &operation->sitesPath );
|
||||||
operation->sitesPath = mpw_path( operation->fullName, mpw_marshall_format_extension( MPMarshalFormatFlat ) );
|
operation->sitesPath = mpw_path( operation->fullName, mpw_marshal_format_extension( MPMarshalFormatFlat ) );
|
||||||
if (operation->sitesPath && (sitesFile = fopen( operation->sitesPath, "r" )))
|
if (operation->sitesPath && (sitesFile = fopen( operation->sitesPath, "r" )))
|
||||||
operation->sitesFormat = MPMarshalFormatFlat;
|
operation->sitesFormat = MPMarshalFormatFlat;
|
||||||
else
|
else
|
||||||
@ -473,14 +473,14 @@ void cli_user(Arguments *args, Operation *operation) {
|
|||||||
fclose( sitesFile );
|
fclose( sitesFile );
|
||||||
|
|
||||||
// Parse file.
|
// Parse file.
|
||||||
MPMarshalInfo *sitesInputInfo = mpw_marshall_read_info( sitesInputData );
|
MPMarshalInfo *sitesInputInfo = mpw_marshal_read_info( sitesInputData );
|
||||||
MPMarshalFormat sitesInputFormat = args->sitesFormat? operation->sitesFormat: sitesInputInfo->format;
|
MPMarshalFormat sitesInputFormat = args->sitesFormat? operation->sitesFormat: sitesInputInfo->format;
|
||||||
MPMarshalError marshallError = { .type = MPMarshalSuccess };
|
MPMarshalError marshalError = { .type = MPMarshalSuccess };
|
||||||
mpw_marshal_info_free( &sitesInputInfo );
|
mpw_marshal_info_free( &sitesInputInfo );
|
||||||
operation->user = mpw_marshall_read( sitesInputData, sitesInputFormat, operation->masterPassword, &marshallError );
|
operation->user = mpw_marshal_read( sitesInputData, sitesInputFormat, operation->masterPassword, &marshalError );
|
||||||
if (marshallError.type == MPMarshalErrorMasterPassword && operation->allowPasswordUpdate) {
|
if (marshalError.type == MPMarshalErrorMasterPassword && operation->allowPasswordUpdate) {
|
||||||
// Update master password in mpsites.
|
// Update master password in mpsites.
|
||||||
while (marshallError.type == MPMarshalErrorMasterPassword) {
|
while (marshalError.type == MPMarshalErrorMasterPassword) {
|
||||||
inf( "Given master password does not match configuration.\n" );
|
inf( "Given master password does not match configuration.\n" );
|
||||||
inf( "To update the configuration with this new master password, first confirm the old master password.\n" );
|
inf( "To update the configuration with this new master password, first confirm the old master password.\n" );
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ void cli_user(Arguments *args, Operation *operation) {
|
|||||||
importMasterPassword = mpw_getpass( "Old master password: " );
|
importMasterPassword = mpw_getpass( "Old master password: " );
|
||||||
|
|
||||||
mpw_marshal_free( &operation->user );
|
mpw_marshal_free( &operation->user );
|
||||||
operation->user = mpw_marshall_read( sitesInputData, sitesInputFormat, importMasterPassword, &marshallError );
|
operation->user = mpw_marshal_read( sitesInputData, sitesInputFormat, importMasterPassword, &marshalError );
|
||||||
mpw_free_string( &importMasterPassword );
|
mpw_free_string( &importMasterPassword );
|
||||||
}
|
}
|
||||||
if (operation->user) {
|
if (operation->user) {
|
||||||
@ -500,15 +500,15 @@ void cli_user(Arguments *args, Operation *operation) {
|
|||||||
mpw_free_string( &sitesInputData );
|
mpw_free_string( &sitesInputData );
|
||||||
|
|
||||||
// Incorrect master password.
|
// Incorrect master password.
|
||||||
if (marshallError.type == MPMarshalErrorMasterPassword) {
|
if (marshalError.type == MPMarshalErrorMasterPassword) {
|
||||||
ftl( "Incorrect master password according to configuration:\n %s: %s\n", operation->sitesPath, marshallError.description );
|
ftl( "Incorrect master password according to configuration:\n %s: %s\n", operation->sitesPath, marshalError.description );
|
||||||
cli_free( args, operation );
|
cli_free( args, operation );
|
||||||
exit( EX_DATAERR );
|
exit( EX_DATAERR );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any other parse error.
|
// Any other parse error.
|
||||||
if (!operation->user || marshallError.type != MPMarshalSuccess) {
|
if (!operation->user || marshalError.type != MPMarshalSuccess) {
|
||||||
err( "Couldn't parse configuration file:\n %s: %s\n", operation->sitesPath, marshallError.description );
|
err( "Couldn't parse configuration file:\n %s: %s\n", operation->sitesPath, marshalError.description );
|
||||||
cli_free( args, operation );
|
cli_free( args, operation );
|
||||||
exit( EX_DATAERR );
|
exit( EX_DATAERR );
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ void cli_user(Arguments *args, Operation *operation) {
|
|||||||
|
|
||||||
// If no user from mpsites, create a new one.
|
// If no user from mpsites, create a new one.
|
||||||
if (!operation->user)
|
if (!operation->user)
|
||||||
operation->user = mpw_marshall_user(
|
operation->user = mpw_marshal_user(
|
||||||
operation->fullName, operation->masterPassword, MPAlgorithmVersionCurrent );
|
operation->fullName, operation->masterPassword, MPAlgorithmVersionCurrent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ void cli_site(Arguments __unused *args, Operation *operation) {
|
|||||||
|
|
||||||
// If no site from mpsites, create a new one.
|
// If no site from mpsites, create a new one.
|
||||||
if (!operation->site)
|
if (!operation->site)
|
||||||
operation->site = mpw_marshall_site(
|
operation->site = mpw_marshal_site(
|
||||||
operation->user, operation->siteName, MPResultTypeDefault, MPCounterValueDefault, operation->user->algorithm );
|
operation->user, operation->siteName, MPResultTypeDefault, MPCounterValueDefault, operation->user->algorithm );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,7 +762,7 @@ void cli_save(Arguments __unused *args, Operation *operation) {
|
|||||||
|
|
||||||
if (!operation->sitesFormatFixed)
|
if (!operation->sitesFormatFixed)
|
||||||
operation->sitesFormat = MPMarshalFormatDefault;
|
operation->sitesFormat = MPMarshalFormatDefault;
|
||||||
operation->sitesPath = mpw_path( operation->user->fullName, mpw_marshall_format_extension( operation->sitesFormat ) );
|
operation->sitesPath = mpw_path( operation->user->fullName, mpw_marshal_format_extension( operation->sitesFormat ) );
|
||||||
dbg( "Updating: %s (%s)\n", operation->sitesPath, mpw_nameForFormat( operation->sitesFormat ) );
|
dbg( "Updating: %s (%s)\n", operation->sitesPath, mpw_nameForFormat( operation->sitesFormat ) );
|
||||||
|
|
||||||
FILE *sitesFile = NULL;
|
FILE *sitesFile = NULL;
|
||||||
@ -772,9 +772,9 @@ void cli_save(Arguments __unused *args, Operation *operation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
MPMarshalError marshallError = { .type = MPMarshalSuccess };
|
MPMarshalError marshalError = { .type = MPMarshalSuccess };
|
||||||
if (!mpw_marshall_write( &buf, operation->sitesFormat, operation->user, &marshallError ) || marshallError.type != MPMarshalSuccess)
|
if (!mpw_marshal_write( &buf, operation->sitesFormat, operation->user, &marshalError ) || marshalError.type != MPMarshalSuccess)
|
||||||
wrn( "Couldn't encode updated configuration file:\n %s: %s\n", operation->sitesPath, marshallError.description );
|
wrn( "Couldn't encode updated configuration file:\n %s: %s\n", operation->sitesPath, marshalError.description );
|
||||||
|
|
||||||
else if (fwrite( buf, sizeof( char ), strlen( buf ), sitesFile ) != strlen( buf ))
|
else if (fwrite( buf, sizeof( char ), strlen( buf ), sitesFile ) != strlen( buf ))
|
||||||
wrn( "Error while writing updated configuration file:\n %s: %d\n", operation->sitesPath, ferror( sitesFile ) );
|
wrn( "Error while writing updated configuration file:\n %s: %d\n", operation->sitesPath, ferror( sitesFile ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user