Skip to content

Conversation

@namsic
Copy link
Collaborator

@namsic namsic commented Oct 22, 2025

๐Ÿ”— Related Issue

  • jam2in/arcus-works#791

โŒจ๏ธ What I did

  • config auth_group ๋ช…๋ น์„ ํ†ตํ•ด acl group์„ ์กฐํšŒ/๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
  • ๋ณ€๊ฒฝ ๋Œ€์ƒ acl group์— ํ˜„์žฌ acl group์˜ ์ •๋ณด๊ฐ€ ๋ชจ๋‘ ํฌํ•จ๋œ ๊ฒฝ์šฐ์—๋งŒ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋ณ€๊ฒฝ ์š”์ฒญ์€ ์Šค๋ ˆ๋“œ ์ƒ์„ฑ ํ›„ END ์‘๋‹ตํ•ฉ๋‹ˆ๋‹ค. (์‹ค์ œ ๋ณ€๊ฒฝ ์ž‘์—…์˜ ์„ฑ๊ณต/์‹คํŒจ ์—ฌ๋ถ€์™€ ๋ฌด๊ด€)

@jhpark816 jhpark816 requested a review from ing-eoking October 22, 2025 23:53
@jhpark816
Copy link
Collaborator

@ing-eoking
๋ฆฌ๋ทฐ ์ง„ํ–‰ํ•ด ์ฃผ์„ธ์š”

sasl_auxprop.c Outdated
static const char *zk_root = "/arcus_acl";
static const char *g_ensemble_list;
static char g_group_buf1[GROUP_MAXLEN];
static char g_group_buf2[GROUP_MAXLEN];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_group_buf๊ฐ€ 2๊ฐœ๊ฐ€ ํ•„์š”ํ•œ๊ฐ€์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group์„ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ ์กฐํšŒํ•  ๋•Œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•˜๊ฑฐ๋‚˜ ํ•ด์ œํ•˜๋Š” ๊ตฌํ˜„์„ ๋‹จ์ˆœํ™”ํ•˜๊ธฐ ์œ„ํ•ด ๋‘์—ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator Author

@namsic namsic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜„์žฌ PR์ด ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ๋‚˜ mutex ๊ตฌ์กฐ ๋“ฑ์—์„œ ์ƒ๋‹นํžˆ ๋ณต์žกํ•˜๊ณ  ์ง๊ด€์ ์ด์ง€ ์•Š์€ ํŽธ์ด๊ณ ,
PR ๊ตฌํ˜„์„ ๋ฌด์‹œํ•˜๊ณ  ์™„์ „ํžˆ ์ƒˆ๋กœ์šด ๊ตฌํ˜„์„ ์ œ์‹œํ•ด ์ฃผ์–ด๋„ ๋ฉ๋‹ˆ๋‹ค.

sasl_auxprop.c Outdated
static const char *zk_root = "/arcus_acl";
static const char *g_ensemble_list;
static char g_group_buf1[GROUP_MAXLEN];
static char g_group_buf2[GROUP_MAXLEN];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group์„ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ ์กฐํšŒํ•  ๋•Œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•˜๊ฑฐ๋‚˜ ํ•ด์ œํ•˜๋Š” ๊ตฌํ˜„์„ ๋‹จ์ˆœํ™”ํ•˜๊ธฐ ์œ„ํ•ด ๋‘์—ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋ถ€ ๋ฆฌ๋ทฐ

sasl_auxprop.h Outdated
void arcus_auxprop_wakeup(void);

const char *auxprop_get_acl_group(void);
int auxprop_set_acl_group(const char *group_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์–ด๋–ค ์šฉ์–ด๊ฐ€ ๊ฐ€์žฅ ๋‚˜์€๊ฐ€์š”?

  • acl group
  • auth group
  • user group

memcached.c Outdated
out_string(c, "SERVER_ERROR out of memory");
} else {
pthread_t tid;
int ret = pthread_create(&tid, NULL, sasl_set_auth_group, (void*)config);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sasl_set_auth_group() ํ˜ธ์ถœํ•  thread main loop๋ฅผ ๋”ฐ๋กœ ๋‘์„ธ์š”.

init_sasl_thread() ์ฐธ๊ณ ํ•˜์„ธ์š”.
thread main loop๋Š” memcached.c์— ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

sasl_auxprop.c Outdated
return NULL;
}

snprintf(group_zpath, sizeof(group_zpath), "%s/%s", zk_root, group_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group_zpath๋ฅผ ๋งค๋ฒˆ ๋งŒ๋“ค์ง€ ์•Š๊ณ ,
group_name์ด ๋ณ€๊ฒฝ๋˜๋ฉด 1ํšŒ๋งŒ ๋งŒ๋“ค๋ฉด ๋ฉ๋‹ˆ๋‹ค.

@ing-eoking
Copy link
Collaborator

๊ฐœ์ธ์ ์œผ๋กœ table์„ ๊ต์ฒดํ•˜๋Š” ๋กœ์ง์€ acl_refresh_thread์—์„œ ์ฒ˜๋ฆฌํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

@namsic
Copy link
Collaborator Author

namsic commented Oct 23, 2025

๊ตฌํ˜„ ๋ณ€๊ฒฝ ์ œ์•ˆ

by @ing-eoking

  • config ๋ณ€๊ฒฝ ๋ช…๋ น์€ group name ๋ณ€๊ฒฝ ํ›„ refresh ์š”์ฒญํ•˜๋Š” ํ˜•ํƒœ๋กœ ๊ตฌํ˜„

    • old table๊ณผ ๋น„๊ตํ•˜๋Š” ๋กœ์ง๋„ refresh ์Šค๋ ˆ๋“œ๊ฐ€ ์ˆ˜ํ–‰
    • group name ๋ณ€๊ฒฝ ํ›„ refresh ์š”์ฒญํ–ˆ๋Š”๋ฐ ์ด๋ฏธ ์ง„ํ–‰ ์ค‘์ธ refresh ์ž‘์—…์ด ์žˆ์œผ๋ฉด,
      ๋‹ค์Œ refresh ์ฃผ๊ธฐ๊นŒ์ง€ ๋ฐ˜์˜ ์•ˆ ๋จ
  • group name ์กฐํšŒ ์š”์ฒญ ์‹œ, strdup์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹นํ•˜์—ฌ ๋ฐ˜ํ™˜

    • memcached.c์—์„œ ์‘๋‹ต ๋ฐ˜ํ™˜ ํ›„ free ํ•ด์•ผ ํ•จ
    if (ntokens == 3) {
      char buf[50];
      char *group_name = sasl_get_auth_group();
      sprintf(buf, "auth_group %s\r\nEND", group_name);
      out_string(c, buf);
      free(group_name);
    • ๋˜๋Š”, memcached.c ์—์„œ ๋ฒ„ํผ ์ „๋‹ฌ
    if (ntokens == 3) {
      char buf[50];
      int len = sprintf(buf, "auth group ");
      len += sasl_get_auth_group(buf + len, 50 - len - 5);
      sprintf(buf + len, "\r\nEND");
      out_string(c, buf);
    }

@namsic namsic force-pushed the config_auth_group branch from b4b1af2 to 57a0af5 Compare October 26, 2025 10:34
@jhpark816
Copy link
Collaborator

@namsic
์–ด๋–ค ์ƒํƒœ์ธ๊ฐ€์š”?

@namsic
Copy link
Collaborator Author

namsic commented Oct 27, 2025

์–ด๋–ค ์ƒํƒœ์ธ๊ฐ€์š”?

๋ฆฌ๋ทฐ ์˜๊ฒฌ์— ๋”ฐ๋ผ ๊ตฌํ˜„์„ ์ •๋ฆฌํ•ด ๋‘” ์ƒํƒœ์ด๊ณ , ํ…Œ์ŠคํŠธ ๋ฐ ์ตœ์ข… ๊ฒ€ํ†  ํ›„ ๋ฆฌ๋ทฐ ์žฌ์š”์ฒญํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

@namsic namsic force-pushed the config_auth_group branch from 57a0af5 to 3b6d1f5 Compare October 27, 2025 02:42
Copy link
Collaborator Author

@namsic namsic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋ž˜ ๋ณ€๊ฒฝ์ด ์ ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

  • acl table ๋น„๊ต ๋ฐ group ๋ณ€๊ฒฝ ์ž‘์—…์„ acl refresh thread๊ฐ€ ์ˆ˜ํ–‰
    • auth group ๋ณ€๊ฒฝ ๋ช…๋ น์€ new group name ์„ค์ •ํ•˜๊ณ  reload ์š”์ฒญ
  • old table์„ ๋‹ค์‹œ ์กฐํšŒํ•˜์ง€ ์•Š๊ณ , ๊ธฐ์กด g_sasltable๊ณผ ๋น„๊ต
    • ๋ฝ์„ ์žก์€ ์ƒํƒœ๋กœ ์ˆ˜ํ–‰
  • auth group ์กฐํšŒ ์‹œ strdup ํ•˜์—ฌ ๋ฐ˜ํ™˜
    • ํ˜ธ์ถœํ•œ ์ธก(memcached.c)์—์„œ free ํ•ด์•ผ ํ•จ

์–ด๋–ค ์šฉ์–ด๊ฐ€ ๊ฐ€์žฅ ๋‚˜์€๊ฐ€์š”?

  • acl group
  • auth group
  • user group

์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค๋กœ๋Š” auth group์ด ๊ฐ€์žฅ ๋‚˜์•„ ๋ณด์ž…๋‹ˆ๋‹ค.
๋‚ด๋ถ€ ๊ตฌํ˜„ ์ธก๋ฉด์—์„œ sasl_defs์™€ sasl_auxprop์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌ๋ถ„ํ•ด์•ผ ํ•˜๋Š”๋ฐ,
ํ˜„์žฌ PR์€ ์•„๋ž˜์™€ ๊ฐ™์ด ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

  • sasl_defs์—์„œ: sasl_get_auth_group
  • sasl_auxprop์—์„œ: arcus_auxprop_get_group

@namsic namsic marked this pull request as ready for review October 27, 2025 02:45
@namsic namsic force-pushed the config_auth_group branch from 3b6d1f5 to dfd6eba Compare October 27, 2025 06:01
memcached.c Outdated
if (ntokens == 3) {
char buf[50];
char *group_name = sasl_get_auth_group();
if (!group_name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋ž˜ ๋กœ์ง๊ณผ ๊ฐ™์ด ์„ฑ๊ณต -> ์—๋Ÿฌ ์ˆœ์œผ๋กœ ๋ฐฐ์น˜ํ•˜๋Š” ํŽธ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋ถ€ ๋ฆฌ๋ทฐํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋ฐ˜์˜ํ•˜์ง€ ์•Š์„ PR์ด๋ผ๋„
๋ฒ„๊ทธ๋‚˜ ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ์ด๋ผ๋ฉด ๋ฐ˜์˜ํ•ด ๋‘๋Š” ๊ฒƒ์ด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

sasl_auxprop.c Outdated
mc_logger->log(EXTENSION_LOG_WARNING, NULL,
"SECURITY_EVENT ACL group change to %s failed: missing key %s\n",
new_group_name, old_entry->key);
pthread_mutex_unlock(&g_sasltable_lock);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ œ๊ฑฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

sasl_auxprop.c Outdated
snprintf(g_group_zpath, sizeof(g_group_zpath), "%s", new_group_zpath);
pthread_mutex_unlock(&g_sasltable_lock);

_table_free(old_table);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_valid ๋ณ€์ˆ˜๋ฅผ ๋‘๋Š” ์•„๋ž˜ ํ˜•ํƒœ์˜ ์ฝ”๋“œ๊ฐ€ ์ฝ๊ธฐ์— ๋‚˜์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    char new_key[TABLE_KEY_LEN];
    struct sasl_entry *new_entry;
    bool is_valid = true;
    for (int i = 0; i < SASL_TABLE_SIZE; i++) {
        struct sasl_entry *old_entry = g_sasltable[i];
        while (old_entry) {
            snprintf(new_key, sizeof(new_key), "%s/%s",
                    new_group_zpath, old_entry->key + origin_group_zpath_len);
            new_entry = new_table[hash_function(new_key) % SASL_TABLE_SIZE];
            while (new_entry) {
                if (strcmp(new_entry->key, new_key) == 0 &&
                    new_entry->value_len == old_entry->value_len &&
                    memcmp(new_entry->value, old_entry->value, old_entry->value_len) == 0) {
                    break;
                }
                new_entry = new_entry->next;
            }
            if (new_entry == NULL) { // new_entry not found
                 is_valid = false;
                 break;
            }
            old_entry = old_entry->next;
        }
    }

    if (is_valid) {

    } else {

    }

sasl_auxprop.c Outdated
while (!acl_thread_stopreq) {
ts.tv_sec += REFRESH_PERIOD;
pthread_mutex_lock(&acl_thread_lock);
if (!acl_thread_stopreq) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์กฐ๊ฑด ๋ณ€๊ฒฝ
(!acl_thread_stopreq && !change_acl_group)

sasl_auxprop.c Outdated
mc_logger->log(EXTENSION_LOG_INFO, NULL, "SECURITY_EVENT ACL group changed to: %s\n", g_group_name);
continue;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acl_thread_stopreq ๋ณ€์ˆ˜์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ volatile ๋ณ€์ˆ˜๋กœ ๋‘๊ณ ,
ํ•œ๋ฒˆ true ์„ค์ •๋˜๋ฉด ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์— ์˜ํ•ด false๋กœ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์•„๋ž˜์™€ ๊ฐ™์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

if (change_acl_group) {
    int ret = validate_new_acl_group();
    if (ret != 0) {
       continue;
    }
 }

์ตœ์‹ ์˜ acl_table๊ณผ compareํ•˜์—ฌ valid ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•ด์•ผ ํ•˜๋ฏ€๋กœ,
์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋จผ์ € ์ˆ˜ํ–‰ํ•˜์—ฌ ๊ธฐ์กด acl_table์„ reloadํ•˜๊ณ  ๋‚˜์„œ,
acl group ๋ณ€๊ฒฝ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•˜๋Š” ๊ฒƒ์ด ๋งž์ง€ ์•Š๋‚˜ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

@namsic namsic force-pushed the config_auth_group branch from dfd6eba to d4cb819 Compare October 28, 2025 11:53
Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋ถ€ ๋ฆฌ๋ทฐ

sasl_auxprop.c Outdated
memcmp(new_entry->value, old_entry->value, old_entry->value_len) == 0) {
mc_logger->log(EXTENSION_LOG_WARNING, NULL,
"SECURITY_EVENT ACL group change to %s failed: missing key %s\n",
new_group_name, old_entry->key);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing key %s ์ด๋Ÿฐ ์ถœ๋ ฅ์ด ์ดˆ๊ธฐ PR์— ์žˆ์—ˆ๋‚˜์š”?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ๋ฌธ ์•ˆ์—์„œ๋Š” old_entry์— ํ•ด๋‹นํ•˜๋Š” new_entry๋ฅผ ์ฐพ์€ ์ƒํƒœ์ด๋ฏ€๋กœ, ๋กœ๊ทธ ์ถœ๋ ฅํ•˜๋ฉด ์•ˆ ๋ฉ๋‹ˆ๋‹ค.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing key %s ์ด๋Ÿฐ ์ถœ๋ ฅ์ด ์ดˆ๊ธฐ PR์— ์žˆ์—ˆ๋‚˜์š”?

acl group ๋ณ€๊ฒฝ์€ ๋ชจ๋‘ ๋กœ๊ทธ๋กœ ๋‚จ๊ธด๋‹ค๋Š” ์„ค๊ณ„์— ๋”ฐ๋ผ ์ดˆ๊ธฐ PR์—์„œ๋„ ์‹คํŒจ ์‹œ ๋™์ผํ•œ ๋กœ๊ทธ๋ฅผ ๊ธฐ๋กํ•˜๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

pthread_mutex_unlock(&g_sasltable_lock);
_table_free(old_table);
return 0;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ์œ„์น˜์— ๋กœ๊ทธ ์ถœ๋ ฅ์ด ์˜ค๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

                   mc_logger->log(EXTENSION_LOG_WARNING, NULL,
                        "SECURITY_EVENT ACL group change to %s failed: missing key %s\n",
                        new_group_name, old_entry->key);

}
if (new_entry == NULL) {
is_valid = false;
break;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char *missing_key ๋ณ€์ˆ˜๋ฅผ ๋”ฐ๋กœ ๋‘๊ณ , ์—ฌ๊ธฐ์„œ ์„ค์ •ํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
์•„๋‹ˆ๋ฉด, ์ด ์œ„์น˜์—์„œ ๋กœ๊ทธ ์ถœ๋ ฅํ•ด์•ผ ํ•˜๊ณ ์š”.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing key๋Š” ๋”ฐ๋กœ ๊ธฐ๋กํ•˜์ง€ ์•Š๊ณ , ๋‹จ์ˆœ ์‹คํŒจ ์‚ฌ์‹ค๋งŒ ๋กœ๊ทธ๋กœ ๋‚จ๊ธฐ๋Š” ๊ฒƒ์œผ๋กœ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

if (ret == 0) {
mc_logger->log(EXTENSION_LOG_INFO, NULL, "SECURITY_EVENT ACL group changed to: %s\n", g_group_name);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋ž˜์— ์žˆ๋Š” ๋กœ๊ทธ ์ถœ๋ ฅ์ด ์œ„๋กœ ์˜ฌ๋ผ๊ฐ€์•ผ ํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

sasl_auxprop.c Outdated

acl_thread_running = true;
while (!acl_thread_stopreq) {
ts.tv_sec += REFRESH_PERIOD;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ธฐ์กด ์ฝ”๋“œ์— ๋Œ€ํ•œ ์ฝ”๋ฉ˜ํŠธ์ž…๋‹ˆ๋‹ค.

  • ๋‘ ๋ฒˆ์งธ loop ๋ถ€ํ„ฐ๋Š” ts ๊ฐ’์„ ๋‹ค์‹œ ๊ตฌํ•ด์•ผ ํ•˜์ง€ ์•Š๋Š” ์ง€ ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ดˆ๊ธฐ์—๋Š” init ์‹œ์ ์— ๋žœ๋ค์œผ๋กœ ๊ตฌํ•œ ์˜คํ”„์…‹์„ ๊ธฐ์ค€์œผ๋กœ ๋งค์ผ ๊ฐ™์€ ์‹œ๊ฐ„์— refresh ์‹œ์ž‘๋˜๋Š” ๊ฒƒ์„ ์˜๋„ํ–ˆ๋Š”๋ฐ,

reload auth ๋˜๋Š” config auth_group์ฒ˜๋Ÿผ ์ž„์˜ ์‹œ์ ์— refreshํ•˜๋Š” ๋กœ์ง์ด ์ถ”๊ฐ€๋˜๋ฉด์„œ ๋งž์ง€ ์•Š๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
๋งค loop๋งˆ๋‹ค ts ๊ฐ’์„ ๋‹ค์‹œ ๊ณ„์‚ฐํ•˜๋Š” ํ˜•ํƒœ๋กœ ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namsic
์•„๋ž˜์— ๋Œ€ํ•œ ์ˆ˜์ •์€ ๋ณ„๋„ PR๋กœ ์˜ฌ๋ ค์ฃผ์„ธ์š”.
auth group ๋ณ€๊ฒฝ ๊ธฐ๋Šฅ์€ ๋ฐ˜์˜ํ•˜์ง€ ์•Š์„ ์˜ˆ์ •์ด๊ณ ,
์•„๋ž˜ ์ˆ˜์ •์€ ๊ธฐ์กด ์ฝ”๋“œ์— ๋Œ€ํ•œ ์ˆ˜์ •์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

 clock_gettime(CLOCK_REALTIME, &ts);

๊ทธ๋ฆฌ๊ณ , loop ๋“ค์–ด์˜ค์ง€ ์ „์— random ๋ฐฉ์‹์˜ tv_sec ์„ค์ •ํ•˜๋Š” ์˜๋ฏธ๋„ ์‚ด๋ ค์•ผ ๋˜์ง€ ์•Š๋Š” ์ง€ ?

   clock_gettime(CLOCK_REALTIME, &ts);
    srand(ts.tv_sec);
    ts.tv_sec += rand() % REFRESH_PERIOD;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทธ๋ฆฌ๊ณ , loop ๋“ค์–ด์˜ค์ง€ ์ „์— random ๋ฐฉ์‹์˜ tv_sec ์„ค์ •ํ•˜๋Š” ์˜๋ฏธ๋„ ์‚ด๋ ค์•ผ ๋˜์ง€ ์•Š๋Š” ์ง€ ?

๊ธฐ์กด์—๋Š” ์ดˆ๊ธฐ ๊ตฌ๋™ ์‹œ random offset์„ ์ฃผ์–ด ์‹œ์ ์„ ํฉ์–ด๋†“๊ณ  ๊ทธ ๋’ค๋กœ๋Š” ๊ณ ์ • ์ฃผ๊ธฐ(REFRESH_PERIOD)๋งˆ๋‹ค ๊ฐ’์„ ๊ฐฑ์‹ ํ•˜๋Š” ํ˜•ํƒœ์˜€๊ณ ,
๋‹ค๋ฅธ ์กฐ์ž‘์ด ์—†์œผ๋ฉด ํ•˜๋ฃจ ํ•œ ๋ฒˆ ์กฐํšŒ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

๋งค loop๋งˆ๋‹ค random offset ์„ค์ •ํ•˜๋„๋ก ํ•˜๋ฉด (reload ์ž‘์—… ์—ฌ๋ถ€์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ) REFRESH_PERIOD 24h ๊ฐ’์˜ ์˜๋ฏธ๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์ด ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค.

  • ๊ฐฑ์‹  ์ฃผ๊ธฐ๋Š” ๋งค ๋ฒˆ ๋žœ๋ค์ด๋ฉฐ, ์ตœ๋Œ€ 24H ์ด๋‚ด์— ๊ฐฑ์‹  ๋ณด์žฅ
  • ํ™•๋ฅ ์— ๋”ฐ๋ผ 24H ๋™์•ˆ N๋ฒˆ ๊ฐฑ์‹  ์ž‘์—… ์ˆ˜ํ–‰

๋งค ๋ฒˆ rand ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณ€๊ฒฝํ• ๊นŒ์š”?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ธฐ์กด ๋™์ž‘์€ ์•„๋ž˜์™€ ๊ฐ™์•˜์Šต๋‹ˆ๋‹ค.

  • ์ฒซ ๋ฒˆ์งธ wait duration : (rand() % REFRESH_PERIOD) + REFRESH_PERIOD
  • ๊ทธ ์ดํ›„ wait duration : REFRESH_PERIOD

์–ด๋–ค ์ฝ”๋ฉ˜ํŠธ ์—†์ด ์•„๋ž˜์™€ ๊ฐ™์ด ๋ณ€๊ฒฝ๋˜์–ด์„œ
(rand() % REFRESH_PERIOD) ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์˜€๋Š” ์ง€๋ฅผ ์ฝ”๋ฉ˜ํŠธ๋กœ ๋ฌผ์€ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
ํ˜น์‹œ ์‹ค์ˆ˜๋กœ ํ™•์ธํ•˜์ง€ ๋ชปํ–ˆ์„๊นŒ ๋ด ๋ฌผ์€ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

  • ๋ชจ๋“  wait duration : REFRESH_PERIOD

๊ธฐ์กด ๋™์ž‘๋Œ€๋กœ ํ•ด๋„ ๋˜๊ณ , ๋งค๋ฒˆ rand ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค.
ํŠน์ • ์˜๋„๋กœ ๊ตฌํ˜„ํ•œ ๋ถ€๋ถ„์„ ๋ณ€๊ฒฝํ•œ๋‹ค๋ฉด, ์ด๋ ‡๊ฒŒ ๋ณ€๊ฒฝํ–ˆ๋‹ค๋Š” ์ฝ”๋ฉ˜ํŠธ๋งŒ ๋‚จ๊ฒจ๋‘๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ, REFRESH_PERIOD๋ฅผ 12์‹œ๊ฐ„์œผ๋กœ ์ค„์ด๊ณ , ์•„๋ž˜ ๋ฐฉ์‹์œผ๋กœ ๋งค๋ฒˆ randํ•˜๋ฉด ์ ๋‹นํ•ด ๋ณด์ž…๋‹ˆ๋‹ค.

  • (rand() % REFRESH_PERIOD) + REFRESH_PERIOD

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋งค๋ฒˆ rand ๋ฐฉ์‹์œผ๋กœ ํ•  ๊ฒฝ์šฐ,
์–ด๋–ค rand ๋ฐฉ์‹์œผ๋กœ ํ•˜๋ฉด ์ ๋‹นํ•œ ์ง€๋„ ์Šค์Šค๋กœ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋ด…๋‹ˆ๋‹ค.

sasl_auxprop.c Outdated
change_acl_group = false;
pthread_mutex_unlock(&acl_thread_lock);
if (ret == 0) {
mc_logger->log(EXTENSION_LOG_INFO, NULL, "SECURITY_EVENT ACL group changed to: %s\n", g_group_name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋กœ๊ทธ ์ถœ๋ ฅ์„ validate_new_acl_group() ์•ˆ์— ๋„ฃ๋Š” ๊ฒƒ์ด ์–ด๋–ค์ง€ ?

sasl_auxprop.c Outdated
#define PROPNAME_MAXLEN 32
// 16: buffer for "/arcus_acl", "/" separator, "\0" terminator, etc.
#define TABLE_KEY_LEN 16 + GROUP_MAXLEN + USERNAME_MAXLEN + PROPNAME_MAXLEN
#define VALUE_MAXLEN 8192 /* from Cyrus SASL's sasldb auxprop plugin */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋ž˜ ์šฉ์–ด๊ฐ€ ์–ด๋–ค์ง€?

  • SASL_KEY_MAXLEN
  • SASL_VALUE_MAXLEN

@namsic namsic force-pushed the config_auth_group branch from 8a0fbb4 to 36f02b1 Compare October 30, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants