Skip to content

Commit 6d50230

Browse files
committed
Update all deps, persistent uid for linux plugin
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 6d543a3 commit 6d50230

File tree

7 files changed

+79
-12
lines changed

7 files changed

+79
-12
lines changed

src/DPF

Submodule DPF updated 57 files

src/mod-host

src/mod-plugin-builder

src/mod-ui

src/plugin/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ USING_WEBVIEW = true
3232

3333
include ../DPF/Makefile.plugins.mk
3434

35-
TARGETS = features au clap lv2_sep vst2 vst3
35+
TARGETS = features jack au clap lv2_sep vst2 vst3
3636

3737
BUILD_CXX_FLAGS += -DVERSION='"$(shell cat ../../VERSION)"'
3838
BUILD_CXX_FLAGS += -pthread

src/plugin/utils.cpp

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,21 +360,88 @@ char* const* getEvironment(const uint portBaseNum)
360360
CFRelease(uuidRef);
361361
IOObjectRelease(service);
362362
}
363+
364+
// TODO check if safe
365+
// CFRelease(deviceRef);
363366
}
364367
#elif defined(_WIN32)
365368
// TODO
366369
#else
367-
if (FILE* const f = fopen("/etc/machine-id", "r"))
370+
char uidpath[PATH_MAX] = {};
371+
std::memcpy(uidpath, dataDir, dataDirLen);
372+
std::strncpy(uidpath + dataDirLen, "/device/uid", PATH_MAX - dataDirLen - 1);
373+
374+
// read uid from dataDir if it exists
375+
if (FILE* const fu = std::fopen(uidpath, "rb"))
368376
{
369-
if (fread(path, PATH_MAX - 1, 1, f) == 0 && strlen(path) >= 33)
377+
if (std::fscanf(fu,
378+
"%02hhx:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX",
379+
key,
380+
key + 1,
381+
key + 2,
382+
key + 3,
383+
key + 4,
384+
key + 5,
385+
key + 6,
386+
key + 7,
387+
key + 8,
388+
key + 9,
389+
key + 10,
390+
key + 11,
391+
key + 12,
392+
key + 13,
393+
key + 14,
394+
key + 15) != 16)
395+
std::memset(key, 0, sizeof(key));
396+
397+
std::fclose(fu);
398+
}
399+
400+
// if no previous uid set, generate new one
401+
static constexpr const uint8_t zerokey[16] = {};
402+
if (std::memcmp(key, zerokey, sizeof(key)) == 0)
403+
{
404+
if (FILE* const f = std::fopen("/etc/machine-id", "r"))
370405
{
371-
for (int i=0; i<16; ++i)
406+
if (std::fread(path, PATH_MAX - 1, 1, f) == 0 && std::strlen(path) >= 33)
372407
{
373-
key[i] = char2u8(path[i*2]) << 4;
374-
key[i] |= char2u8(path[i*2+1]) << 0;
408+
for (int i=0; i<16; ++i)
409+
{
410+
key[i] = char2u8(path[i * 2]) << 4;
411+
key[i] |= char2u8(path[i * 2 + 1]) << 0;
412+
}
375413
}
414+
std::fclose(f);
415+
}
416+
417+
if (std::memcmp(key, zerokey, sizeof(key)) == 0)
418+
{
419+
// TODO generate random key
420+
}
421+
422+
// write uid to dataDir, ensuring it is persistent
423+
if (FILE* const fu = std::fopen(uidpath, "wb"))
424+
{
425+
std::fprintf(fu,
426+
"%02hhx:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX",
427+
key[0],
428+
key[1],
429+
key[2],
430+
key[3],
431+
key[4],
432+
key[5],
433+
key[6],
434+
key[7],
435+
key[8],
436+
key[9],
437+
key[10],
438+
key[11],
439+
key[12],
440+
key[13],
441+
key[14],
442+
key[15]);
443+
std::fclose(fu);
376444
}
377-
fclose(f);
378445
}
379446
#endif
380447

0 commit comments

Comments
 (0)