다음 코드는 cap_enter 줄을 제거하면 예상대로 작동합니다. 그러나 내 프로그램이 기능 모드로 실행되는지 확인하고 싶습니다.명령 줄 프로그램에서 입력 된 기록 저장 (캐 패티 모드에서)
나는이 프로그램을 4000+ 큰 프로그램에서 최소한의 예제로 뽑아 냈다.
내가 프로그램을 실행하려면 ktrace를 사용하고 난 다음 줄 참조 출력이 kdump : 열 RET -1 errno는 94
52225 시험은 주위에 기능 모드
에서 허용되지 않음을 요점 나는 역사를 원했다.
기능 모드와 기록을 모두 사용할 수 있습니까?
#include <err.h>
#include <errno.h>
#include <histedit.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/capsicum.h>
static const char* promptstr = "";
static const char * prompt(EditLine *e __unused) {
return promptstr;
}
-
int
main(int argc __unused, char **argv)
{
History *inhistory;
EditLine *el;
HistEvent ev;
inhistory = history_init();
el = el_init(argv[0], stdin, stdout, stderr);
el_set(el, EL_PROMPT, &prompt);
el_set(el, EL_EDITOR, "emacs");
el_set(el, EL_SIGNAL, 1);
el_set(el, EL_HIST, history, inhistory);
el_source(el, NULL);
history(inhistory, &ev, H_SETSIZE, 50);
if (inhistory == 0)
err(1, "Could not initalize history");
if (cap_enter() < 0)
err(1, "unable to enter capability mode");
for (;;) {
const char* havestr;
int inputsz;
havestr = el_gets(el, &inputsz);
if (havestr == NULL)
exit(0);
if (inputsz > 0)
history(inhistory, &ev, H_ENTER, havestr);
if (*havestr == '.')
break;
}
history(inhistory, &ev, H_SAVE, "/tmp/myhistory");
history_end(inhistory);
return(0);
}